File tree 4 files changed +40
-0
lines changed
regression/ansi-c/gcc_attributes13
4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ // GCC statement attributes -- currently "fallthrough" is the only one that GCC
2
+ // supports.
3
+ // https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html
4
+
5
+ int main ()
6
+ {
7
+ int x ;
8
+ switch (x )
9
+ {
10
+ case 1 :
11
+ x = 2 ;
12
+ #ifdef __GNUC__
13
+ __attribute__((fallthrough ));
14
+ #endif
15
+ case 2 :
16
+ x = 3 ;
17
+ }
18
+
19
+ return 0 ;
20
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ --
7
+ ^warning: ignoring
8
+ ^CONVERSION ERROR$
Original file line number Diff line number Diff line change @@ -148,6 +148,7 @@ extern char *yyansi_ctext;
148
148
%token TOK_GCC_ATTRIBUTE_NORETURN " noreturn"
149
149
%token TOK_GCC_ATTRIBUTE_CONSTRUCTOR " constructor"
150
150
%token TOK_GCC_ATTRIBUTE_DESTRUCTOR " destructor"
151
+ %token TOK_GCC_ATTRIBUTE_FALLTHROUGH " fallthrough"
151
152
%token TOK_GCC_LABEL " __label__"
152
153
%token TOK_MSC_ASM " __asm"
153
154
%token TOK_MSC_BASED " __based"
@@ -2156,6 +2157,7 @@ statement:
2156
2157
| msc_asm_statement
2157
2158
| msc_seh_statement
2158
2159
| cprover_exception_statement
2160
+ | statement_attribute
2159
2161
;
2160
2162
2161
2163
declaration_statement :
@@ -2214,6 +2216,14 @@ labeled_statement:
2214
2216
}
2215
2217
;
2216
2218
2219
+ statement_attribute :
2220
+ TOK_GCC_ATTRIBUTE ' (' ' (' TOK_GCC_ATTRIBUTE_FALLTHROUGH ' )' ' )' ' ;' labeled_statement
2221
+ {
2222
+ // attribute ignored
2223
+ $$ =$8 ;
2224
+ }
2225
+ ;
2226
+
2217
2227
compound_statement :
2218
2228
compound_scope ' {' ' }'
2219
2229
{
Original file line number Diff line number Diff line change @@ -1580,6 +1580,8 @@ __decltype { if(PARSER.cpp98 &&
1580
1580
" destructor" |
1581
1581
" __destructor__" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_DESTRUCTOR; }
1582
1582
1583
+ " fallthrough" { BEGIN (GCC_ATTRIBUTE3); loc (); return TOK_GCC_ATTRIBUTE_FALLTHROUGH; }
1584
+
1583
1585
{ws } { /* ignore */ }
1584
1586
{newline } { /* ignore */ }
1585
1587
{identifier } { BEGIN (GCC_ATTRIBUTE4); }
You can’t perform that action at this time.
0 commit comments