File tree Expand file tree Collapse file tree 3 files changed +27
-22
lines changed
regression/ansi-c/gcc_attributes13 Expand file tree Collapse file tree 3 files changed +27
-22
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,20 @@ int main()
77 int x ;
88 switch (x )
99 {
10- case 1 :
11- x = 2 ;
10+ case 1 :
11+ x = 2 ;
1212#ifdef __GNUC__
13- __attribute__((fallthrough ));
13+ __attribute__((fallthrough ));
1414#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 ;
1724 }
1825
1926 return 0 ;
Original file line number Diff line number Diff line change @@ -1655,6 +1655,11 @@ gcc_attribute:
16551655 {
16561656 init ($$);
16571657 }
1658+ | TOK_GCC_ATTRIBUTE_FALLTHROUGH
1659+ {
1660+ // attribute ignored
1661+ init ($$);
1662+ }
16581663 | gcc_type_attribute
16591664 ;
16601665
@@ -2320,19 +2325,7 @@ declaration_statement:
23202325 ;
23212326
23222327labeled_statement :
2323- identifier_or_typedef_name ' :' gcc_attribute_specifier ' ;'
2324- {
2325- /* Only semicolons permitted after the attribute:
2326- https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html */
2327- $$ =$2 ;
2328- statement ($$, ID_label);
2329- irep_idt identifier=PARSER.lookup_label(parser_stack($1 ).get(ID_C_base_name));
2330- parser_stack ($$).set(ID_label, identifier);
2331- // attribute ignored
2332- statement ($3 , ID_skip);
2333- mto ($$, $3 );
2334- }
2335- | identifier_or_typedef_name ' :' statement
2328+ identifier_or_typedef_name ' :' statement
23362329 {
23372330 $$ =$2 ;
23382331 statement ($$, ID_label);
@@ -2367,10 +2360,14 @@ labeled_statement:
23672360 ;
23682361
23692362statement_attribute :
2370- TOK_GCC_ATTRIBUTE ' ( ' ' ( ' TOK_GCC_ATTRIBUTE_FALLTHROUGH ' ) ' ' ) ' ' ; ' labeled_statement
2363+ gcc_attribute_specifier ' ; '
23712364 {
2372- // attribute ignored
2373- $$ =$8 ;
2365+ // Really should only be TOK_GCC_ATTRIBUTE_FALLTHROUGH or a label
2366+ // attribute. Only semicolons permitted after the attribute:
2367+ // https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html
2368+ // We ignore all such attributes.
2369+ $$ =$1 ;
2370+ statement ($$, ID_skip);
23742371 }
23752372 ;
23762373
Original file line number Diff line number Diff line change @@ -1704,7 +1704,8 @@ __decltype { if(PARSER.cpp98 &&
17041704" destructor" |
17051705" __destructor__" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_DESTRUCTOR; }
17061706
1707- " fallthrough" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_FALLTHROUGH; }
1707+ " fallthrough" |
1708+ " __fallthrough__" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_FALLTHROUGH; }
17081709
17091710" used" |
17101711" __used__" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_USED; }
You can’t perform that action at this time.
0 commit comments