Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / c-c++-common / attr-fallthrough-1.c
blobecfd094d9cd8052f64a04ed35366f431a5cf83f7
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall -Wextra -Wpedantic" } */
5 extern void bar (int);
6 void
7 fn (int i)
9 __attribute__((fallthrough)) int j = 0; /* { dg-warning "ignored|attribute not followed" } */
11 if (j)
12 __attribute__((fallthrough)); /* { dg-error "invalid use" } */
14 __attribute__((fallthrough)); /* { dg-error "invalid use" } */
15 switch (i)
17 __attribute__((fallthrough)); /* { dg-warning "statement will never" } */
18 case 1:
19 i++;
20 __attribute__((fallthrough));
21 case 2:
22 if (i) /* { dg-warning "statement may fall through" } */
23 bar (2);
24 else
25 __attribute__((fallthrough));
26 case 3:
27 if (i > 1)
28 __attribute__((fallthrough));
29 else
30 return;
31 case 4:
32 if (i)
33 __attribute__((fallthrough)); /* { dg-warning "not preceding" } */
34 __attribute__((fallthrough));
35 case 5:
37 __attribute__((fallthrough));
38 case 6:
39 if (i) /* { dg-warning "statement may fall through" } */
40 bar (6);
41 else
43 __attribute__((fallthrough));
45 case 7:
46 if (i > 1)
48 __attribute__((fallthrough));
50 else
51 bar (7); /* { dg-warning "statement may fall through" } */
52 default:
53 --j;
56 __attribute__((fallthrough)); /* { dg-error "invalid use" } */