Skip to content

Commit 5d0f97a

Browse files
author
Hana Dusíková
committed
added -pedantic -Wall -Wextra
1 parent a722d7e commit 5d0f97a

File tree

16 files changed

+46
-38
lines changed

16 files changed

+46
-38
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TARGETS := result.cpp test.cpp $(wildcard tests/benchmark-exec/*.cpp)
66

77
DESATOMAT := /www/root/desatomat/console/desatomat.php
88

9-
CXXFLAGS := -std=c++17 -Iinclude -O3 -Wno-gnu-string-literal-operator-template
9+
CXXFLAGS := -std=c++17 -Iinclude -O3 -Wno-gnu-string-literal-operator-template -pedantic -Wall -Wextra
1010
#-Xclang -fconcepts-ts
1111
LDFLAGS := -lpcre2-8
1212

include/ctll/actions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace ctll {
2020
template <typename Actions> struct augment_actions<false, Actions>: public Actions {
2121
using Actions::apply;
2222
// will fail if unknown action is called
23+
constexpr static auto apply(...) = delete;
2324
};
2425
}
2526

include/ctll/fixed_string.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ template <typename CharT, size_t N> class basic_fixed_string {
3737
template <typename CharT> class basic_fixed_string<CharT, 0> {
3838
public:
3939
using char_type = CharT;
40-
constexpr basic_fixed_string(const CharT(&)[0]) noexcept { }
40+
constexpr basic_fixed_string(const CharT *) noexcept { }
4141
constexpr size_t size() const noexcept {
4242
return 0;
4343
}

include/ctll/grammars.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ struct pop_input {
3535
};
3636

3737
// additional overloads for type list
38-
template <typename... Ts> constexpr auto push_front(pop_input, list<Ts...>) -> list<Ts...> { return {}; };
38+
template <typename... Ts> constexpr auto push_front(pop_input, list<Ts...>) -> list<Ts...> { return {}; }
3939

40-
template <typename... Ts> constexpr auto push_front(epsilon, list<Ts...>) -> list<Ts...> { return {}; };
40+
template <typename... Ts> constexpr auto push_front(epsilon, list<Ts...>) -> list<Ts...> { return {}; }
4141

42-
template <typename... As, typename... Bs> constexpr auto push_front(list<As...>, list<Bs...>) -> list<As..., Bs...> { return {}; };
42+
template <typename... As, typename... Bs> constexpr auto push_front(list<As...>, list<Bs...>) -> list<As..., Bs...> { return {}; }
4343

4444
template <typename T, typename... As> constexpr auto pop_front_and_push_front(T item, list<As...> l) {
4545
return push_front(item, pop_front(l));

include/ctll/list.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ template <typename... Ts> constexpr auto size(list<Ts...>) noexcept { return siz
1616

1717

1818
// check if the list is empty
19-
template <typename... Ts> constexpr bool empty(list<Ts...>) noexcept { return false; };
20-
constexpr bool empty(empty_list) { return true; };
19+
template <typename... Ts> constexpr bool empty(list<Ts...>) noexcept { return false; }
20+
constexpr bool empty(empty_list) { return true; }
2121

2222

2323
// concat two lists together left to right
24-
template <typename... As, typename... Bs> constexpr auto concat(list<As...>, list<Bs...>) noexcept -> list<As..., Bs...> { return {}; };
24+
template <typename... As, typename... Bs> constexpr auto concat(list<As...>, list<Bs...>) noexcept -> list<As..., Bs...> { return {}; }
2525

2626

2727
// push something to the front of a list
28-
template <typename T, typename... As> constexpr auto push_front(T, list<As...>) noexcept -> list<T, As...> { return {}; };
28+
template <typename T, typename... As> constexpr auto push_front(T, list<As...>) noexcept -> list<T, As...> { return {}; }
2929

3030

3131
// pop element from the front of a list
32-
template <typename T, typename... As> constexpr auto pop_front(list<T, As...>) noexcept -> list<As...> { return {}; };
32+
template <typename T, typename... As> constexpr auto pop_front(list<T, As...>) noexcept -> list<As...> { return {}; }
3333
constexpr auto pop_front(empty_list) -> empty_list;
3434

3535
// pop element from the front of a list and return new typelist too
@@ -39,13 +39,13 @@ template <typename Front, typename List> struct list_pop_pair {
3939
constexpr list_pop_pair() = default;
4040
};
4141

42-
template <typename Head, typename... As, typename T = _nothing> constexpr auto pop_and_get_front(list<Head, As...>, T = T()) noexcept -> list_pop_pair<Head, list<As...>> { return {}; };
43-
template <typename T = _nothing> constexpr auto pop_and_get_front(empty_list, T = T()) noexcept -> list_pop_pair<T, empty_list> { return {}; };
42+
template <typename Head, typename... As, typename T = _nothing> constexpr auto pop_and_get_front(list<Head, As...>, T = T()) noexcept -> list_pop_pair<Head, list<As...>> { return {}; }
43+
template <typename T = _nothing> constexpr auto pop_and_get_front(empty_list, T = T()) noexcept -> list_pop_pair<T, empty_list> { return {}; }
4444

4545

4646
// return front of the list
47-
template <typename Head, typename... As, typename T = _nothing> constexpr auto front(list<Head, As...>, T = T()) noexcept -> Head { return {}; };
48-
template <typename T = _nothing> constexpr auto front(empty_list, T = T()) noexcept -> T { return {}; };
47+
template <typename Head, typename... As, typename T = _nothing> constexpr auto front(list<Head, As...>, T = T()) noexcept -> Head { return {}; }
48+
template <typename T = _nothing> constexpr auto front(empty_list, T = T()) noexcept -> T { return {}; }
4949

5050

5151
}

include/ctll/parser.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ template <typename Grammar, basic_fixed_string input, typename ActionSelector =
5858
}
5959
// if rule is pop_input => move to next character
6060
template <size_t Pos, typename Terminal, typename Stack, typename Subject>
61-
static constexpr auto move(ctll::pop_input, Terminal, Stack stack, Subject subject) noexcept {
61+
static constexpr auto move(ctll::pop_input, Terminal, Stack, Subject) noexcept {
6262
return seed<Pos+1, Stack, Subject, decision::undecided>();
6363
}
6464
// if rule is string => push it to the front of stack
@@ -74,21 +74,21 @@ template <typename Grammar, basic_fixed_string input, typename ActionSelector =
7474
// if rule is string with current character at the beginning (term<V>) => move to next character
7575
// and push string without the character (quick LL(1))
7676
template <size_t Pos, auto V, typename... Content, typename Stack, typename Subject>
77-
static constexpr auto move(ctll::list<term<V>, Content...> string, term<V>, Stack stack, Subject subject) noexcept {
77+
static constexpr auto move(ctll::list<term<V>, Content...>, term<V>, Stack stack, Subject) noexcept {
7878
return seed<Pos+1, decltype(push_front(list<Content...>(), stack)), Subject, decision::undecided>();
7979
}
8080
// if rule is string with any character at the beginning (compatible with current term<T>) => move to next character
8181
// and push string without the character (quick LL(1))
8282
template <size_t Pos, auto V, typename... Content, auto T, typename Stack, typename Subject>
83-
static constexpr auto move(ctll::list<anything, Content...> string, term<T>, Stack stack, Subject subject) noexcept {
83+
static constexpr auto move(ctll::list<anything, Content...>, term<T>, Stack stack, Subject) noexcept {
8484
return seed<Pos+1, decltype(push_front(list<Content...>(), stack)), Subject, decision::undecided>();
8585
}
8686
// decide if we need to take action or move
8787
template <size_t Pos, typename Stack, typename Subject> static constexpr auto decide(Stack previous_stack, Subject previous_subject) noexcept {
8888
// each call means we pop something from stack
8989
auto top_symbol = decltype(ctll::front(previous_stack, empty_stack_symbol()))();
90-
auto stack = decltype(ctll::pop_front(previous_stack))();
91-
//auto [top_symbol, stack] = pop_and_get_front(previous_stack, empty_stack_symbol());
90+
// gcc pedantic warning
91+
[[maybe_unused]] auto stack = decltype(ctll::pop_front(previous_stack))();
9292

9393
// in case top_symbol is action type (apply it on previous subject and get new one)
9494
if constexpr (std::is_base_of_v<ctll::action, decltype(top_symbol)>) {
@@ -132,7 +132,7 @@ template <typename Grammar, basic_fixed_string input, typename ActionSelector =
132132
};
133133

134134
// trampolines with folded expression
135-
template <typename Subject, size_t... Pos> static constexpr auto trampoline_decide(Subject default_subject, std::index_sequence<Pos...>) noexcept {
135+
template <typename Subject, size_t... Pos> static constexpr auto trampoline_decide(Subject, std::index_sequence<Pos...>) noexcept {
136136
// parse everything for first char and than for next and next ...
137137
// Pos+1 is needed as we want to finish calculation with epsilons on stack
138138
return (seed<0, decltype(grammar.start_stack), Subject, decision::undecided>::parse() + ... + placeholder<Pos+1>());
@@ -143,9 +143,9 @@ template <typename Grammar, basic_fixed_string input, typename ActionSelector =
143143
return trampoline_decide(subject, std::make_index_sequence<input.size()>());
144144
}
145145

146-
template <typename Subject = empty_subject> using output = decltype(trampoline_decide(Subject()));
146+
template <typename Subject = empty_subject> using output = decltype(trampoline_decide<Subject>());
147147
static inline constexpr bool correct = trampoline_decide(empty_subject());
148-
template <typename Subject = empty_subject> static inline constexpr bool correct_with = trampoline_decide(Subject());
148+
template <typename Subject = empty_subject> static inline constexpr bool correct_with = trampoline_decide<Subject>();
149149
};
150150

151151
} // end of ctll namespace

include/ctre/actions/backreference.inc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ template <auto V, size_t Id, typename... Ts, size_t Counter> static constexpr au
1717
}
1818

1919
// relative backreference
20-
template <auto V, size_t Id, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_relative_back_reference, ctll::term<V>, pcre_context<ctll::list<number<Id>, Ts...>, pcre_parameters<Counter>> subject) {
20+
template <auto V, size_t Id, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_relative_back_reference, ctll::term<V>, [[maybe_unused]] pcre_context<ctll::list<number<Id>, Ts...>, pcre_parameters<Counter>> subject) {
2121
// if we are looking outside of existing list of Ids ... reject input during parsing
2222
if constexpr (Counter < Id) {
2323
return ctll::reject{};

include/ctre/actions/capture.inc.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#define CTRE__ACTIONS__CAPTURE__HPP
33

44
// capture
5-
template <auto V, typename A, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture, ctll::term<V>, pcre_context<ctll::list<A, Ts...>, pcre_parameters<Counter>> subject) {
5+
template <auto V, typename A, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture, ctll::term<V>, pcre_context<ctll::list<A, Ts...>, pcre_parameters<Counter>>) {
66
return pcre_context{ctll::push_front(capture<Counter+1, A>(), ctll::list<Ts...>()), pcre_parameters<Counter+1>()};
77
}
88
// capture (sequence)
9-
template <auto V, typename... Content, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture, ctll::term<V>, pcre_context<ctll::list<sequence<Content...>, Ts...>, pcre_parameters<Counter>> subject) {
9+
template <auto V, typename... Content, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture, ctll::term<V>, pcre_context<ctll::list<sequence<Content...>, Ts...>, pcre_parameters<Counter>>) {
1010
return pcre_context{ctll::push_front(capture<Counter+1, Content...>(), ctll::list<Ts...>()), pcre_parameters<Counter+1>()};
1111
}
1212
// push_name
@@ -18,11 +18,11 @@ template <auto... Str, auto V, typename... Ts, typename Parameters> static const
1818
return pcre_context{ctll::push_front(id<Str..., V>(), ctll::list<Ts...>()), subject.parameters};
1919
}
2020
// capture with name
21-
template <auto... Str, auto V, typename A, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture_with_name, ctll::term<V>, pcre_context<ctll::list<A, id<Str...>, Ts...>, pcre_parameters<Counter>> subject) {
21+
template <auto... Str, auto V, typename A, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture_with_name, ctll::term<V>, pcre_context<ctll::list<A, id<Str...>, Ts...>, pcre_parameters<Counter>>) {
2222
return pcre_context{ctll::push_front(capture_with_name<Counter+1, id<Str...>, A>(), ctll::list<Ts...>()), pcre_parameters<Counter+1>()};
2323
}
2424
// capture with name (sequence)
25-
template <auto... Str, auto V, typename... Content, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture_with_name, ctll::term<V>, pcre_context<ctll::list<sequence<Content...>, id<Str...>, Ts...>, pcre_parameters<Counter>> subject) {
25+
template <auto... Str, auto V, typename... Content, typename... Ts, size_t Counter> static constexpr auto apply(pcre::make_capture_with_name, ctll::term<V>, pcre_context<ctll::list<sequence<Content...>, id<Str...>, Ts...>, pcre_parameters<Counter>>) {
2626
return pcre_context{ctll::push_front(capture_with_name<Counter+1, id<Str...>, Content...>(), ctll::list<Ts...>()), pcre_parameters<Counter+1>()};
2727
}
2828

include/ctre/actions/set.inc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// UTILITY
55
// add into set if not exists
6-
template <template <typename...> typename SetType, typename T, typename... As, bool Exists = (std::is_same_v<T, As> || ... || false)> static constexpr auto push_back_into_set(T, SetType<As...>) -> ctll::conditional<Exists, SetType<As...>, SetType<As...,T>> { return {}; };
6+
template <template <typename...> typename SetType, typename T, typename... As, bool Exists = (std::is_same_v<T, As> || ... || false)> static constexpr auto push_back_into_set(T, SetType<As...>) -> ctll::conditional<Exists, SetType<As...>, SetType<As...,T>> { return {}; }
77

88
//template <template <typename...> typename SetType, typename A, typename BHead, typename... Bs> struct set_merge_helper {
99
// using step = decltype(push_back_into_set<SetType>(BHead(), A()));

include/ctre/atoms_characters.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ template <auto V> struct character {
2424
};
2525

2626
struct any {
27-
template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value) noexcept { return true; }
27+
template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT) noexcept { return true; }
2828
};
2929

3030
template <typename... Content> struct negative_set {

0 commit comments

Comments
 (0)