File tree 5 files changed +68
-3
lines changed
enum_with_underlying_type
function_with_postfix_attributes 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:
1837
1837
}
1838
1838
;
1839
1839
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
+
1840
1848
enum_underlying_type_opt :
1841
1849
/* empty */
1842
1850
{
1843
1851
init ($$);
1844
1852
parser_stack ($$).make_nil();
1845
1853
}
1846
- | ' :' basic_type_name
1854
+ | ' :' enum_underlying_type
1847
1855
{
1848
1856
$$ =$2 ;
1849
1857
}
@@ -2995,14 +3003,14 @@ function_head:
2995
3003
PARSER.add_declarator (parser_stack ($$), parser_stack ($1 ));
2996
3004
create_function_scope ($$);
2997
3005
}
2998
- | declaration_specifier declarator
3006
+ | declaration_specifier declarator post_declarator_attributes_opt
2999
3007
{
3000
3008
init ($$, ID_declaration);
3001
3009
parser_stack ($$).type ().swap (parser_stack ($1 ));
3002
3010
PARSER.add_declarator (parser_stack ($$), parser_stack ($2 ));
3003
3011
create_function_scope ($$);
3004
3012
}
3005
- | type_specifier declarator
3013
+ | type_specifier declarator post_declarator_attributes_opt
3006
3014
{
3007
3015
init ($$, ID_declaration);
3008
3016
parser_stack ($$).type ().swap (parser_stack ($1 ));
You can’t perform that action at this time.
0 commit comments