From a8ce85adbf2863e98e5c24e9cc6f82947d4b3a29 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 21 Jul 2020 18:42:27 +0200 Subject: Support _Static_assert from C11 --- cparser/pre_parser.mly | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cparser/pre_parser.mly') diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 669ecf5e..6ba7ee39 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -57,7 +57,7 @@ AUTO REGISTER INLINE NORETURN CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE UNDERSCORE_BOOL CONST VOLATILE VOID STRUCT UNION ENUM CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN BUILTIN_VA_ARG ALIGNOF - ATTRIBUTE ALIGNAS PACKED ASM BUILTIN_OFFSETOF + ATTRIBUTE ALIGNAS PACKED ASM BUILTIN_OFFSETOF STATIC_ASSERT %token EOF @@ -404,6 +404,7 @@ expression: declaration(phantom): | declaration_specifiers(declaration(phantom)) init_declarator_list? SEMICOLON | declaration_specifiers_typedef typedef_declarator_list? SEMICOLON +| static_assert_declaration {} init_declarator_list: @@ -518,6 +519,7 @@ struct_declaration_list: struct_declaration: | specifier_qualifier_list(struct_declaration) struct_declarator_list? SEMICOLON +| static_assert_declaration {} (* As in the standard, except it also encodes the constraint described @@ -607,6 +609,10 @@ gcc_attribute_word: | PACKED {} +static_assert_declaration: +| STATIC_ASSERT LPAREN constant_expression COMMA STRING_LITERAL RPAREN SEMICOLON + {} + function_specifier: | INLINE | NORETURN -- cgit From 0132b8aa669adc10e6ca953d10d5c0b861f304b1 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 27 Jul 2020 19:05:27 +0200 Subject: Allow string_literals_list in _Static_assert. Not all pre-processors concatenate string literal lists, however they are allowed in _Static_assert. This is similar to the rules for inline assembly etc. --- cparser/pre_parser.mly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cparser/pre_parser.mly') diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 6ba7ee39..4b62b235 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -610,7 +610,7 @@ gcc_attribute_word: {} static_assert_declaration: -| STATIC_ASSERT LPAREN constant_expression COMMA STRING_LITERAL RPAREN SEMICOLON +| STATIC_ASSERT LPAREN constant_expression COMMA string_literals_list RPAREN SEMICOLON {} function_specifier: -- cgit