Skip to content

Commit 5bc7361

Browse files
Accept attribute on null statement without warning
1 parent 76222c3 commit 5bc7361

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/frontc/cparser.mly

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,11 +874,12 @@ local_label_names:
874874
| IDENT COMMA local_label_names { fst $1 :: $3 }
875875
;
876876

877-
878-
879877
statement:
880-
SEMICOLON {NOP ((*handleLoc*) $1) }
881-
| comma_expression SEMICOLON
878+
| attribute_nocv_list SEMICOLON {NOP ((*handleLoc*) $2) }
879+
| statement_no_null { $1 }
880+
881+
statement_no_null:
882+
comma_expression SEMICOLON
882883
{COMPUTATION (smooth_expression (fst $1), joinLoc (snd $1) $2)}
883884
| block {BLOCK (fst3 $1, joinLoc (snd3 $1) (trd3 $1))}
884885
| IF paren_comma_expression location statement location %prec IF
@@ -894,12 +895,18 @@ statement:
894895
| FOR LPAREN for_clause opt_expression
895896
SEMICOLON opt_expression RPAREN statement location
896897
{FOR ($3, $4, $6, $8, joinLoc $1 $9, joinLoc $2 $7)}
897-
| IDENT COLON attribute_nocv_list location statement
898+
| IDENT COLON attribute_nocv_list location statement_no_null
898899
{(* The only attribute that should appear here
899900
is "unused". For now, we drop this on the
900901
floor, since unused labels are usually
901902
removed anyways by Rmtmps. *)
902903
LABEL (fst $1, $5, joinLoc (snd $1) $4)}
904+
| IDENT COLON attribute_nocv_list location SEMICOLON
905+
{(* The only attribute that should appear here
906+
is "unused". For now, we drop this on the
907+
floor, since unused labels are usually
908+
removed anyways by Rmtmps. *)
909+
LABEL (fst $1, NOP ($5), joinLoc (snd $1) $4)}
903910
| CASE expression COLON statement location
904911
{CASE (fst $2, $4, joinLoc $1 $5, joinLoc $1 $3)}
905912
| CASE expression ELLIPSIS expression COLON statement location

test/small1/fallthrough-label.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
int main() {
2+
int a =5;
3+
4+
switch(a) {
5+
case 5:
6+
__attribute__((__fallthrough__));
7+
default:
8+
a = 8;
9+
}
10+
11+
return 0;
12+
}

test/testcil.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ sub addToGroup {
376376
addTest("testrun/flexible-array-member ");
377377
addTest("test-bad1/flexible-array-member-bad ");
378378

379+
addTest("testrun/fallthrough-label");
380+
379381
addTest("testrun/label1");
380382
addTest("testrun/label2");
381383
addTest("testrun/label3");

0 commit comments

Comments
 (0)