PR middle-end/77674
[official-gcc.git] / gcc / testsuite / c-c++-common / Wimplicit-fallthrough-1.c
blobb45880f19b4e9d66b7712213075036e65a2b10fc
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wimplicit-fallthrough" } */
4 /* Test taken from
5 <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0188r0.pdf>. */
7 extern void f (int);
9 void
10 foo (int n)
12 switch (n)
14 case 22:
15 case 33:
16 f (1); /* { dg-warning "statement may fall through" } */
17 case 44:
18 f (2);
19 __attribute__((fallthrough));
20 case 55:
21 if (n > 10)
23 f (3);
24 break;
26 else
28 f (4);
29 __attribute__((fallthrough));
31 case 66:
32 f (5);
33 __attribute__((fallthrough)); /* { dg-warning "not preceding" } */
34 f (6); /* { dg-warning "statement may fall through" } */
35 case 77:
36 f (7);