Skip to content

Commit 0503985

Browse files
author
Hana Dusíková
committed
disable thinks which makes ICE of GCC9 also disable tests with UDL
1 parent 4ce44b2 commit 0503985

File tree

13 files changed

+101
-37
lines changed

13 files changed

+101
-37
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
default: all
44

55
TARGETS := a.cpp result.cpp test.cpp $(wildcard tests/benchmark-exec/*.cpp)
6-
IGNORE := $(wildcard tests/benchmark/*.cpp) $(wildcard tests/benchmark-exec/*.cpp) tests/trampoline.cpp
6+
IGNORE := $(wildcard tests/benchmark/*.cpp) $(wildcard tests/benchmark-exec/*.cpp)
77

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

1010
CPP_STANDARD := $(shell ./cpp-20-check.sh $(CXX))
1111

1212
CXXFLAGS := $(CPP_STANDARD) -Iinclude -O3 -Wno-gnu-string-literal-operator-template -pedantic -Wall -Wextra
1313
LDFLAGS :=
14-
#-lpcre2-8 -lboost_regex -lre2
1514

1615
TESTS := $(wildcard tests/*.cpp) $(wildcard tests/benchmark/*.cpp)
1716
TRUE_TARGETS := $(TARGETS:%.cpp=%)
@@ -26,7 +25,7 @@ list:
2625
echo $(SUPPORTED_CPP20)
2726

2827
$(TRUE_TARGETS): %: %.o
29-
$(CXX) $< $(LDFLAGS) -o $@ > /dev/null
28+
$(CXX) $< $(LDFLAGS) -o $@
3029

3130
$(OBJECTS): %.o: %.cpp
3231
$(CXX) $(CXXFLAGS) -MMD -c $< -o $@

cpp-20-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if echo "" | $1 -std=c++2a -E -x c++ - 2>/dev/null 1>/dev/null; then
44
if [ -z "$VERSION" ]; then
55
echo "-std=c++2a";
66
else
7-
echo "-std=c++2a -DISABLE_GNU_EXTENSION_LITERALS";
7+
echo "-std=c++2a -DEXPERIMENTAL_GCC_9";
88
fi
99
else
1010
echo "-std=c++17";

include/ctll/parser.hpp

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@ enum class decision {
1515
undecided
1616
};
1717

18-
template <typename T> void id(T);
19-
2018
struct placeholder { };
2119

22-
template <bool Correct, typename Subject> struct result_of_parsing {
20+
template <size_t> using index_placeholder = placeholder;
21+
22+
#ifdef EXPERIMENTAL_GCC_9
23+
template <size_t, typename, typename Subject, decision Decision> struct results {
2324
constexpr operator bool() const noexcept {
24-
return Correct;
25+
return Decision == decision::accept;
2526
}
2627
using output_type = Subject;
2728
};
29+
#endif
30+
2831

2932
#if !__cpp_nontype_template_parameter_class
3033
template <typename Grammar, const auto & input, typename ActionSelector = empty_actions, bool IgnoreUnknownActions = false> struct parser {
@@ -34,6 +37,25 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
3437
using Actions = ctll::conditional<IgnoreUnknownActions, ignore_unknown<ActionSelector>, identity<ActionSelector>>;
3538
using grammar = augment_grammar<Grammar>;
3639

40+
#ifndef EXPERIMENTAL_GCC_9
41+
template <size_t Pos, typename Stack, typename Subject, decision Decision> struct results {
42+
constexpr inline CTLL_FORCE_INLINE operator bool() const noexcept {
43+
return Decision == decision::accept;
44+
}
45+
46+
using output_type = Subject;
47+
48+
constexpr auto operator+(placeholder) const noexcept {
49+
if constexpr (Decision == decision::undecided) {
50+
// parse for current char (RPos) with previous stack and subject :)
51+
return decide<Pos, Stack, Subject>({}, {});
52+
} else {
53+
// if there is decision already => just push it to the end of fold expression
54+
return *this;
55+
}
56+
}
57+
};
58+
#endif
3759

3860
template <size_t Pos> static constexpr auto get_current_term() noexcept {
3961
if constexpr (Pos < input.size()) {
@@ -56,17 +78,21 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
5678
// if rule is accept => return true and subject
5779
template <size_t Pos, typename Terminal, typename Stack, typename Subject>
5880
static constexpr auto move(ctll::accept, Terminal, Stack, Subject) noexcept {
59-
return result_of_parsing<true, Subject>{};
81+
return results<Pos, Stack, Subject, decision::accept>();
6082
}
6183
// if rule is reject => return false and subject
6284
template <size_t Pos, typename Terminal, typename Stack, typename Subject>
6385
static constexpr auto move(ctll::reject, Terminal, Stack, Subject) noexcept {
64-
return result_of_parsing<false, Subject>{};
86+
return results<Pos, Stack, Subject, decision::reject>();
6587
}
6688
// if rule is pop_input => move to next character
6789
template <size_t Pos, typename Terminal, typename Stack, typename Subject>
68-
static constexpr auto move(ctll::pop_input, Terminal, Stack stack, Subject subject) noexcept {
69-
return decide<Pos+1>(stack, subject);
90+
static constexpr auto move(ctll::pop_input, Terminal, Stack, Subject) noexcept {
91+
#ifdef EXPERIMENTAL_GCC_9
92+
return decide<Pos+1>(Stack(), Subject());
93+
#else
94+
return results<Pos+1, Stack, Subject, decision::undecided>();
95+
#endif
7096
}
7197
// if rule is string => push it to the front of stack
7298
template <size_t Pos, typename... Content, typename Terminal, typename Stack, typename Subject>
@@ -81,17 +107,22 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
81107
// if rule is string with current character at the beginning (term<V>) => move to next character
82108
// and push string without the character (quick LL(1))
83109
template <size_t Pos, auto V, typename... Content, typename Stack, typename Subject>
84-
static constexpr auto move(ctll::list<term<V>, Content...>, term<V>, Stack stack, Subject subject) noexcept {
85-
return decide<Pos+1>(push_front(list<Content...>(), stack), subject);
86-
//return seed<Pos+1, decltype(push_front(list<Content...>(), stack)), Subject, decision::undecided>();
110+
static constexpr auto move(ctll::list<term<V>, Content...>, term<V>, Stack stack, Subject) noexcept {
111+
#ifdef EXPERIMENTAL_GCC_9
112+
return decide<Pos+1>(push_front(list<Content...>(), stack), Subject());
113+
#else
114+
return results<Pos+1, decltype(push_front(list<Content...>(), stack)), Subject, decision::undecided>();
115+
#endif
87116
}
88117
// if rule is string with any character at the beginning (compatible with current term<T>) => move to next character
89118
// and push string without the character (quick LL(1))
90119
template <size_t Pos, auto V, typename... Content, auto T, typename Stack, typename Subject>
91-
static constexpr auto move(ctll::list<anything, Content...>, term<T>, Stack stack, Subject subject) noexcept {
92-
return decide<Pos+1>(push_front(list<Content...>(), stack), subject);
93-
94-
//return seed<Pos+1, decltype(push_front(list<Content...>(), stack)), Subject, decision::undecided>();
120+
static constexpr auto move(ctll::list<anything, Content...>, term<T>, Stack stack, Subject) noexcept {
121+
#ifdef EXPERIMENTAL_GCC_9
122+
return decide<Pos+1>(push_front(list<Content...>(), stack), Subject());
123+
#else
124+
return results<Pos+1, decltype(push_front(list<Content...>(), stack)), Subject, decision::undecided>();
125+
#endif
95126
}
96127
// decide if we need to take action or move
97128
template <size_t Pos, typename Stack, typename Subject> static constexpr auto decide(Stack previous_stack, Subject previous_subject) noexcept {
@@ -106,7 +137,11 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
106137

107138
// in case that semantic action is error => reject input
108139
if constexpr (std::is_same_v<ctll::reject, decltype(subject)>) {
109-
return result_of_parsing<false, Subject>();
140+
#ifndef EXPERIMENTAL_GCC_9
141+
return results<Pos, Stack, Subject, decision::reject>();
142+
#else
143+
return results<Pos, Stack, Subject, decision::reject>();
144+
#endif
110145
} else {
111146
return decide<Pos>(stack, subject);
112147
}
@@ -118,9 +153,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
118153
}
119154
}
120155

121-
template <size_t> using index_placeholder = placeholder;
122-
123-
#if false
156+
#ifndef EXPERIMENTAL_GCC_9
124157
// trampolines with folded expression
125158
template <typename Subject, size_t... Pos> static constexpr auto trampoline_decide(Subject, std::index_sequence<Pos...>) noexcept {
126159
// parse everything for first char and than for next and next ...
@@ -133,11 +166,16 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
133166
// there will be no recursion, just sequence long as the input
134167
return trampoline_decide(subject, std::make_index_sequence<input.size()>());
135168
}
136-
#endif
137169

170+
template <typename Subject = empty_subject> using output = decltype(trampoline_decide<Subject>());
171+
static inline constexpr bool correct = trampoline_decide<empty_subject>();
172+
template <typename Subject = empty_subject> static inline constexpr bool correct_with = trampoline_decide<Subject>();
173+
#else
138174
template <typename Subject = empty_subject> using output = decltype(decide<0, typename grammar::start_stack, Subject>({}, {}));
139175
static inline constexpr bool correct = decide<0, typename grammar::start_stack, empty_subject>({}, {});
140176
template <typename Subject = empty_subject> static inline constexpr bool correct_with = decide<0, typename grammar::start_stack, Subject>({}, {});
177+
#endif
178+
141179
};
142180

143181
} // end of ctll namespace

include/ctre/functions.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ constexpr auto & _input = input;
4747

4848
// in moment when we get C++20 support this will start to work :)
4949

50-
template <typename T> void identify(T);
51-
5250
#if __cpp_nontype_template_parameter_class
5351
template <ctll::basic_fixed_string input> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto match(std::string_view sv) noexcept {
5452
constexpr auto _input = input; // workaround for GCC 9 bug 88092

include/ctre/literals.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ template <typename CharT, CharT... input> static inline constexpr auto _fixed_st
2121
namespace literals {
2222

2323
#ifndef _MSC_VER
24-
#ifndef ISABLE_GNU_EXTENSION_LITERALS
24+
#ifndef EXPERIMENTAL_GCC_9
2525

2626
// add this when we will have concepts
2727
// requires ctll::parser<ctre::pcre, _fixed_string_reference<CharT, charpack...>, ctre::pcre_actions>::template correct_with<pcre_context<>>
@@ -55,7 +55,7 @@ template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr CTRE_FORCE_I
5555
namespace test_literals {
5656

5757
#ifndef _MSC_VER
58-
#ifndef ISABLE_GNU_EXTENSION_LITERALS
58+
#ifndef EXPERIMENTAL_GCC_9
5959

6060
#if !__cpp_nontype_template_parameter_class
6161
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr inline auto operator""_ctre_test() noexcept {

tests/generating.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <ctre.hpp>
22

3+
#if false
34
using namespace ctre::test_literals;
45

56
#ifdef DEBUG
@@ -147,3 +148,5 @@ static_assert(same_f("^$"_ctre_gen, ctre::sequence<ctre::assert_begin, ctre::ass
147148
static_assert(same_f("^abc$"_ctre_gen, ctre::sequence<ctre::assert_begin, ctre::character<'a'>,ctre::character<'b'>,ctre::character<'c'>, ctre::assert_end>()));
148149

149150
static_assert(same_f("^a|b$"_ctre_gen, ctre::select<ctre::sequence<ctre::assert_begin, ctre::character<'a'>>, ctre::sequence<ctre::character<'b'>, ctre::assert_end>>()));
151+
152+
#endif

tests/many-of-same-proto.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <ctre.hpp>
22
using namespace ctre::test_literals;
3+
#ifndef EXPERIMENTAL_GCC_9
34
static_assert("(tour|to|tournament)+\ntourna"_ctre_test);
45
static_assert("(tour|to|tournament)+\ntourna"_ctre_test);
56
static_assert("(tour|to|tournament)+\ntourna"_ctre_test);
@@ -3000,3 +3001,4 @@ static_assert("(tour|to|tournament)+\ntourna"_ctre_test);
30003001
static_assert("(tour|to|tournament)+\ntourna"_ctre_test);
30013002
static_assert("(tour|to|tournament)+\ntourna"_ctre_test);
30023003
static_assert("(tour|to|tournament)+\ntourna"_ctre_test);
3004+
#endif

tests/matching2.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ using namespace ctre::literals;
55
using namespace ctre::test_literals;
66
using namespace std::string_view_literals;
77

8+
#ifndef EXPERIMENTAL_GCC_9
9+
810
static_assert(""_ctre.search("abc"sv));
911
static_assert("abc"_ctre.match("abc"sv));
1012

@@ -206,3 +208,4 @@ static_assert("((a)(b))"_ctre.match("ab"sv).template get<1>() == "ab"sv);
206208
static_assert("((a)(b))"_ctre.match("ab"sv).template get<2>() == "a"sv);
207209
static_assert("((a)(b))"_ctre.match("ab"sv).template get<3>() == "b"sv);
208210

211+
#endif

tests/matching3.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ using namespace std::string_view_literals;
77

88
#if __cpp_nontype_template_parameter_class
99

10-
#define TEST_MATCH(id, pattern, subject) static_assert(ctre::match<_ptn>(subject))
10+
#define TEST_MATCH(id, pattern, subject) static_assert(ctre::match<pattern>(subject))
1111

12-
#define TEST_SEARCH(id, pattern, subject) static_assert(ctre::search<_ptn>(subject))
12+
#define TEST_SEARCH(id, pattern, subject) static_assert(ctre::search<pattern>(subject))
1313

14-
#define TEST_NOT_MATCH(id, pattern, subject) static_assert(!ctre::match<_ptn>(subject))
14+
#define TEST_NOT_MATCH(id, pattern, subject) static_assert(!ctre::match<pattern>(subject))
1515

16-
#define TEST_NOT_SEARCH(id, pattern, subject) static_assert(!ctre::search<_ptn>(subject))
16+
#define TEST_NOT_SEARCH(id, pattern, subject) static_assert(!ctre::search<pattern>(subject))
1717

1818
#else
1919

tests/msvc.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,25 @@ static_assert(ctre::re<pattern1>().match("123456789"sv));
1111
static_assert(ctre::re<pattern2>().match(""sv));
1212

1313
template <auto & ptn> constexpr bool re() {
14-
return ctll::parser<ctre::pcre, ptn, ctre::pcre_actions>::template correct_with<ctre::pcre_context<>>;
14+
#if __cpp_nontype_template_parameter_class
15+
constexpr auto _ptn = ptn;
16+
#else
17+
constexpr auto & _ptn = ptn;
18+
#endif
19+
return ctll::parser<ctre::pcre, _ptn, ctre::pcre_actions>::template correct_with<ctre::pcre_context<>>;
1520
}
1621

1722
static_assert(re<pattern2>());
1823

19-
static inline constexpr ctre::pattern pat = "hello";
24+
static inline constexpr ctll::basic_fixed_string pat = "hello";
2025

2126
template <auto & ptn> constexpr bool re2() {
22-
return ctll::parser<ctre::pcre, ptn, ctre::pcre_actions>::template correct_with<ctre::pcre_context<>>;
27+
#if __cpp_nontype_template_parameter_class
28+
constexpr auto _ptn = ptn;
29+
#else
30+
constexpr auto & _ptn = ptn;
31+
#endif
32+
return ctll::parser<ctre::pcre, _ptn, ctre::pcre_actions>::template correct_with<ctre::pcre_context<>>;
2333
}
2434

2535
static_assert(re<pat>());

0 commit comments

Comments
 (0)