libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / c23-attr-fallthrough-2.c
blobec4732106fcfa47830a8022f1d66540c0ea961c6
1 /* Test C23 attribute syntax. Invalid use of fallthrough attribute. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c23 -pedantic-errors -Wextra" } */
5 [[fallthrough]]; /* { dg-error "'fallthrough' attribute at top level" } */
7 int [[fallthrough]] x; /* { dg-error "ignored" } */
9 int g () [[fallthrough]]; /* { dg-error "ignored" } */
11 int array[2] [[fallthrough]]; /* { dg-error "ignored" } */
13 int z = sizeof (int [[fallthrough]]); /* { dg-error "ignored" } */
15 int
16 f (int a)
18 [[fallthrough]] int b = 2; /* { dg-warning "not followed by" } */
19 /* { dg-error "ignored" "ignored" { target *-*-* } .-1 } */
20 switch (a)
22 case 1:
23 b = 1; /* { dg-warning "may fall through" } */
24 case 2:
25 b = 2; /* { dg-warning "may fall through" } */
26 [[fallthrough()]]; /* { dg-error "does not take any arguments" } */
27 case 3:
28 b += 7;
29 break;
30 case 4:
31 b = 4; /* { dg-warning "may fall through" } */
32 [[fallthrough(1)]]; /* { dg-error "does not take any arguments|expected" } */
33 case 5:
34 b += 5;
35 break;
36 [[fallthrough]] case 6: break; /* { dg-error "ignored" } */
37 [[fallthrough]] default: break; /* { dg-error "ignored" } */
39 [[fallthrough]] return b; /* { dg-error "ignored" } */
40 [[fallthrough]] label: ; /* { dg-error "ignored" } */
41 goto label;