File tree 3 files changed +27
-22
lines changed
regression/ansi-c/gcc_attributes13 3 files changed +27
-22
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,20 @@ int main()
7
7
int x ;
8
8
switch (x )
9
9
{
10
- case 1 :
11
- x = 2 ;
10
+ case 1 :
11
+ x = 2 ;
12
12
#ifdef __GNUC__
13
- __attribute__((fallthrough ));
13
+ __attribute__((fallthrough ));
14
14
#endif
15
- case 2 :
16
- x = 3 ;
15
+ case 2 :
16
+ {
17
+ x = 3 ;
18
+ #ifdef __GNUC__
19
+ __attribute__((__fallthrough__ ));
20
+ #endif
21
+ }
22
+ case 3 :
23
+ break ;
17
24
}
18
25
19
26
return 0 ;
Original file line number Diff line number Diff line change @@ -1642,6 +1642,11 @@ gcc_attribute:
1642
1642
{
1643
1643
init ($$);
1644
1644
}
1645
+ | TOK_GCC_ATTRIBUTE_FALLTHROUGH
1646
+ {
1647
+ // attribute ignored
1648
+ init ($$);
1649
+ }
1645
1650
| gcc_type_attribute
1646
1651
;
1647
1652
@@ -2307,19 +2312,7 @@ declaration_statement:
2307
2312
;
2308
2313
2309
2314
labeled_statement :
2310
- identifier_or_typedef_name ' :' gcc_attribute_specifier ' ;'
2311
- {
2312
- /* Only semicolons permitted after the attribute:
2313
- https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html */
2314
- $$ =$2 ;
2315
- statement ($$, ID_label);
2316
- irep_idt identifier=PARSER.lookup_label(parser_stack($1 ).get(ID_C_base_name));
2317
- parser_stack ($$).set(ID_label, identifier);
2318
- // attribute ignored
2319
- statement ($3 , ID_skip);
2320
- mto ($$, $3 );
2321
- }
2322
- | identifier_or_typedef_name ' :' statement
2315
+ identifier_or_typedef_name ' :' statement
2323
2316
{
2324
2317
$$ =$2 ;
2325
2318
statement ($$, ID_label);
@@ -2354,10 +2347,14 @@ labeled_statement:
2354
2347
;
2355
2348
2356
2349
statement_attribute :
2357
- TOK_GCC_ATTRIBUTE ' ( ' ' ( ' TOK_GCC_ATTRIBUTE_FALLTHROUGH ' ) ' ' ) ' ' ; ' labeled_statement
2350
+ gcc_attribute_specifier ' ; '
2358
2351
{
2359
- // attribute ignored
2360
- $$ =$8 ;
2352
+ // Really should only be TOK_GCC_ATTRIBUTE_FALLTHROUGH or a label
2353
+ // attribute. Only semicolons permitted after the attribute:
2354
+ // https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html
2355
+ // We ignore all such attributes.
2356
+ $$ =$1 ;
2357
+ statement ($$, ID_skip);
2361
2358
}
2362
2359
;
2363
2360
Original file line number Diff line number Diff line change @@ -1701,7 +1701,8 @@ __decltype { if(PARSER.cpp98 &&
1701
1701
" destructor" |
1702
1702
" __destructor__" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_DESTRUCTOR; }
1703
1703
1704
- " fallthrough" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_FALLTHROUGH; }
1704
+ " fallthrough" |
1705
+ " __fallthrough__" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_FALLTHROUGH; }
1705
1706
1706
1707
" used" |
1707
1708
" __used__" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_USED; }
You can’t perform that action at this time.
0 commit comments