gcc/testsuite/gcc.dg/c11-labels-2.c
raw| 1 | /* Tests for labels before declarations and at ends of compound statements. */ |
| 2 | /* { dg-do compile } */ |
| 3 | /* { dg-options "-std=c11 -pedantic" } */ |
| 4 | |
| 5 | int f(int x) |
| 6 | { |
| 7 | goto b; |
| 8 | a: int i = 2 * x; /* { dg-warning "a label can only be part of a statement and a declaration is not a statement" } */ |
| 9 | goto c; |
| 10 | b: goto a; |
| 11 | { i *= 3; c: } /* { dg-warning "label at end of compound statement" } */ |
| 12 | return i; |
| 13 | d: /* { dg-warning "label at end of compound statement" } */ |
| 14 | } |
| 15 |