diff --git a/regression/ansi-c/enum_with_underlying_type/test.c b/regression/ansi-c/enum_with_underlying_type/test.c new file mode 100644 index 00000000000..161f374e279 --- /dev/null +++ b/regression/ansi-c/enum_with_underlying_type/test.c @@ -0,0 +1,19 @@ +typedef unsigned short USHORT; + +enum A : USHORT +{ + AV +}; +enum B : unsigned short +{ + BV +}; +enum C : signed long long +{ + CV +}; + +int main(void) +{ + return 0; +} diff --git a/regression/ansi-c/enum_with_underlying_type/test.desc b/regression/ansi-c/enum_with_underlying_type/test.desc new file mode 100644 index 00000000000..efa98944095 --- /dev/null +++ b/regression/ansi-c/enum_with_underlying_type/test.desc @@ -0,0 +1,12 @@ +CORE +test.c + +^EXIT=0$ +^SIGNAL=0$ +-- +^PARSING ERROR$ +-- +A previous attempt to allow underlying type specifications didn't allow typedef +names or multi word types (e.g. unsigned int). We still don't actually fully +apply the underlying type to the enum, but this at least lets us use parse code +that uses this feature. diff --git a/regression/ansi-c/function_with_postfix_attributes/test.c b/regression/ansi-c/function_with_postfix_attributes/test.c new file mode 100644 index 00000000000..17362cd8c91 --- /dev/null +++ b/regression/ansi-c/function_with_postfix_attributes/test.c @@ -0,0 +1,15 @@ +inline int inline_function_with_postfix_attributes(void) + __attribute__((not_a_real_attribute)) +{ + return 0; +} + +int non_inline_with_postfix_attributes(void) + __attribute__((not_a_real_attribute)) +{ + return 0; +} + +int main(void) +{ +} diff --git a/regression/ansi-c/function_with_postfix_attributes/test.desc b/regression/ansi-c/function_with_postfix_attributes/test.desc new file mode 100644 index 00000000000..928ab2ac2ca --- /dev/null +++ b/regression/ansi-c/function_with_postfix_attributes/test.desc @@ -0,0 +1,11 @@ +CORE gcc-only +test.c + +^EXIT=0$ +^SIGNAL=0$ +-- +^PARSING ERROR$ +-- +gcc doesn't support postfix attributes but clang does, and Apples CoreFoundation framework makes use of this for availability macros. + +Testing both the inline and non-inline variants because these are different cases in our parser. diff --git a/src/ansi-c/parser.y b/src/ansi-c/parser.y index 53bfb7e1d20..1eb5f211682 100644 --- a/src/ansi-c/parser.y +++ b/src/ansi-c/parser.y @@ -1837,13 +1837,21 @@ enum_name: } ; +basic_type_name_list: + basic_type_name + | basic_type_name_list basic_type_name + +enum_underlying_type: + basic_type_name_list + | typedef_name + enum_underlying_type_opt: /* empty */ { init($$); parser_stack($$).make_nil(); } - | ':' basic_type_name + | ':' enum_underlying_type { $$=$2; } @@ -2995,14 +3003,14 @@ function_head: PARSER.add_declarator(parser_stack($$), parser_stack($1)); create_function_scope($$); } - | declaration_specifier declarator + | declaration_specifier declarator post_declarator_attributes_opt { init($$, ID_declaration); parser_stack($$).type().swap(parser_stack($1)); PARSER.add_declarator(parser_stack($$), parser_stack($2)); create_function_scope($$); } - | type_specifier declarator + | type_specifier declarator post_declarator_attributes_opt { init($$, ID_declaration); parser_stack($$).type().swap(parser_stack($1));