From: Erik P. <epe...@iv...> - 2013-04-01 04:39:34
|
On Sun, 31 Mar 2013, Philipp Klaus Krause wrote: > I've done the attached while trying to implement static assertions, but > it gives me SIGSEGV even on a simple test file, such as > > void f(void){ > > _Static_assert (0, "First"); > > _Static_assert (1, "Second"); > > } > > Anyone knowing more about the parser that would see the problem? > > Philipp If you do not specify an action for a rule, the default action is { $$ = $1; } So the result of the static_assert_declaration static_assert_declaration : STATIC_ASSERT '(' constant_expr ',' string_literal_val ')' is the value of the STATIC_ASSERT token, which is fine. But when static_assert_declaration is used as part of a possible rule for declaration without an action | static_assert_declaration ';' ; the default action then passes the STATIC_ASSERT token value from the static_assert_declaration result as the result of the declaration, which was expected to be of type pointer to symbol. I think returning a null symbol pointer should work here and fix the SIGSEGV: | static_assert_declaration ';' { $$ = NULL; } ; Erik |