File tree Expand file tree Collapse file tree 5 files changed +68
-3
lines changed
enum_with_underlying_type
function_with_postfix_attributes Expand file tree Collapse file tree 5 files changed +68
-3
lines changed Original file line number Diff line number Diff line change 1+ typedef unsigned short USHORT ;
2+
3+ enum A : USHORT
4+ {
5+ AV
6+ };
7+ enum B : unsigned short
8+ {
9+ BV
10+ };
11+ enum C : signed long long
12+ {
13+ CV
14+ };
15+
16+ int main (void )
17+ {
18+ return 0 ;
19+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ test.c
3+
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ --
7+ ^PARSING ERROR$
8+ --
9+ A previous attempt to allow underlying type specifications didn't allow typedef
10+ names or multi word types (e.g. unsigned int). We still don't actually fully
11+ apply the underlying type to the enum, but this at least lets us use parse code
12+ that uses this feature.
Original file line number Diff line number Diff line change 1+ inline int inline_function_with_postfix_attributes (void )
2+ __attribute__((not_a_real_attribute ))
3+ {
4+ return 0 ;
5+ }
6+
7+ int non_inline_with_postfix_attributes (void )
8+ __attribute__((not_a_real_attribute ))
9+ {
10+ return 0 ;
11+ }
12+
13+ int main (void )
14+ {
15+ }
Original file line number Diff line number Diff line change 1+ CORE gcc-only
2+ test.c
3+
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ --
7+ ^PARSING ERROR$
8+ --
9+ gcc doesn't support postfix attributes but clang does, and Apples CoreFoundation framework makes use of this for availability macros.
10+
11+ Testing both the inline and non-inline variants because these are different cases in our parser.
Original file line number Diff line number Diff line change @@ -1837,13 +1837,21 @@ enum_name:
18371837 }
18381838 ;
18391839
1840+ basic_type_name_list :
1841+ basic_type_name
1842+ | basic_type_name_list basic_type_name
1843+
1844+ enum_underlying_type :
1845+ basic_type_name_list
1846+ | typedef_name
1847+
18401848enum_underlying_type_opt :
18411849 /* empty */
18421850 {
18431851 init ($$);
18441852 parser_stack ($$).make_nil();
18451853 }
1846- | ' :' basic_type_name
1854+ | ' :' enum_underlying_type
18471855 {
18481856 $$ =$2 ;
18491857 }
@@ -2995,14 +3003,14 @@ function_head:
29953003 PARSER.add_declarator (parser_stack ($$), parser_stack ($1 ));
29963004 create_function_scope ($$);
29973005 }
2998- | declaration_specifier declarator
3006+ | declaration_specifier declarator post_declarator_attributes_opt
29993007 {
30003008 init ($$, ID_declaration);
30013009 parser_stack ($$).type ().swap (parser_stack ($1 ));
30023010 PARSER.add_declarator (parser_stack ($$), parser_stack ($2 ));
30033011 create_function_scope ($$);
30043012 }
3005- | type_specifier declarator
3013+ | type_specifier declarator post_declarator_attributes_opt
30063014 {
30073015 init ($$, ID_declaration);
30083016 parser_stack ($$).type ().swap (parser_stack ($1 ));
You can’t perform that action at this time.
0 commit comments