Debian Codegraph @

gcc/testsuite/gcc.dg/c23-attr-fallthrough-1.c

raw
1 /* Test C23 attribute syntax. Valid use of fallthrough attribute. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c23 -pedantic-errors -Wextra" } */
4
5 int
6 f (int a, int c)
7 {
8 int b = 2;
9 switch (a)
10 {
11 case 1:
12 b = 1; /* { dg-warning "may fall through" } */
13 case 2:
14 b = 2;
15 [[fallthrough]];
16 case 3:
17 b += 7;
18 break;
19 case 4:
20 b = 5;
21 [[__fallthrough__]];
22 case 5:
23 b += 1;
24 break;
25 case 6:
26 if (c == 2)
27 {
28 [[fallthrough]];
29 }
30 else
31 {
32 [[fallthrough]];
33 }
34 case 7:
35 b += 3;
36 [[fallthrough]];
37 default:
38 b += 8;
39 break;
40 }
41 return b;
42 }