88
99#include < limits>
1010
11+ // this is disabling TRAMPOLINING for GCC9 which causes ICE
12+ #if __GNUC__ == 9 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 0
13+ #ifndef CTRE_ENABLE_TRAMPOLINING_ON_GCC9
14+ #define CTRE_DISABLE_TRAMPOLINING 1
15+ #endif
16+ #endif
17+
1118namespace ctll {
1219
1320
@@ -21,7 +28,7 @@ struct placeholder { };
2128
2229template <size_t > using index_placeholder = placeholder;
2330
24- #ifdef EXPERIMENTAL_GCC_9
31+ #ifdef CTRE_DISABLE_TRAMPOLINING
2532template <size_t , typename , typename Subject, decision Decision> struct results {
2633 constexpr operator bool () const noexcept {
2734 return Decision == decision::accept;
@@ -39,7 +46,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
3946 using Actions = ctll::conditional<IgnoreUnknownActions, ignore_unknown<ActionSelector>, identity<ActionSelector>>;
4047 using grammar = augment_grammar<Grammar>;
4148
42- #ifndef EXPERIMENTAL_GCC_9
49+ #ifndef CTRE_DISABLE_TRAMPOLINING
4350 template <size_t Pos, typename Stack, typename Subject, decision Decision> struct results {
4451 constexpr inline CTLL_FORCE_INLINE operator bool () const noexcept {
4552 return Decision == decision::accept;
@@ -101,7 +108,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
101108 // if rule is pop_input => move to next character
102109 template <size_t Pos, typename Terminal, typename Stack, typename Subject>
103110 static constexpr auto move (ctll::pop_input, Terminal, Stack, Subject) noexcept {
104- #ifdef EXPERIMENTAL_GCC_9
111+ #ifdef CTRE_DISABLE_TRAMPOLINING
105112 return decide<Pos+1 >(Stack (), Subject ());
106113 #else
107114 return results<Pos+1 , Stack, Subject, decision::undecided>();
@@ -121,7 +128,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
121128 // and push string without the character (quick LL(1))
122129 template <size_t Pos, auto V, typename ... Content, typename Stack, typename Subject>
123130 static constexpr auto move (push<term<V>, Content...>, term<V>, Stack stack, Subject) noexcept {
124- #ifdef EXPERIMENTAL_GCC_9
131+ #ifdef CTRE_DISABLE_TRAMPOLINING
125132 return decide<Pos+1 >(push_front (list<Content...>(), stack), Subject ());
126133 #else
127134 return results<Pos+1 , decltype (push_front (list<Content...>(), stack)), Subject, decision::undecided>();
@@ -131,7 +138,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
131138 // and push string without the character (quick LL(1))
132139 template <size_t Pos, auto V, typename ... Content, auto T, typename Stack, typename Subject>
133140 static constexpr auto move (push<anything, Content...>, term<T>, Stack stack, Subject) noexcept {
134- #ifdef EXPERIMENTAL_GCC_9
141+ #ifdef CTRE_DISABLE_TRAMPOLINING
135142 return decide<Pos+1 >(push_front (list<Content...>(), stack), Subject ());
136143 #else
137144 return results<Pos+1 , decltype (push_front (list<Content...>(), stack)), Subject, decision::undecided>();
@@ -150,7 +157,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
150157
151158 // in case that semantic action is error => reject input
152159 if constexpr (std::is_same_v<ctll::reject, decltype (subject)>) {
153- #ifndef EXPERIMENTAL_GCC_9
160+ #ifndef CTRE_DISABLE_TRAMPOLINING
154161 return results<Pos, Stack, Subject, decision::reject>();
155162 #else
156163 return results<Pos, Stack, Subject, decision::reject>();
@@ -166,7 +173,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
166173 }
167174 }
168175
169- #ifndef EXPERIMENTAL_GCC_9
176+ #ifndef CTRE_DISABLE_TRAMPOLINING
170177 // trampolines with folded expression
171178 template <typename Subject, size_t ... Pos> static constexpr auto trampoline_decide (Subject, std::index_sequence<Pos...>) noexcept {
172179 // parse everything for first char and than for next and next ...
0 commit comments