1 // PR c/7652
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wextra -Wall -Wpedantic" }
4 
5 extern void bar (int);
6 void
fn(int i)7 fn (int i)
8 {
9   [[gnu::fallthrough]] int j = 0; // { dg-warning "attribute ignored" }
10 
11   if (j)
12     [[gnu::fallthrough]];  // { dg-error "invalid use" }
13 
14   [[gnu::fallthrough]];  // { dg-error "invalid use" }
15   switch (i)
16   {
17     [[gnu::fallthrough]]; // { dg-warning "statement will never" }
18   case 1:
19    i++;
20    [[gnu::fallthrough]];
21   case 2:
22     if (i) // { dg-warning "statement may fall through" }
23       bar (2);
24     else
25       [[gnu::fallthrough]];
26   case 3:
27     if (i > 1)
28       [[gnu::fallthrough]];
29     else
30       return;
31   case 4:
32     if (i)
33       [[gnu::fallthrough]]; // { dg-warning "not preceding" }
34     [[gnu::fallthrough]];
35   case 5:
36    ;
37    [[gnu::fallthrough]];
38   case 6:
39     if (i) // { dg-warning "statement may fall through" }
40       bar (6);
41     else
42       {
43 	[[gnu::fallthrough]];
44       }
45   case 7:
46     if (i > 1)
47       {
48 	[[gnu::fallthrough]];
49       }
50     else
51       bar (7); // { dg-warning "statement may fall through" }
52   default:
53     --j;
54   }
55 
56   [[gnu::fallthrough]]; // { dg-error "invalid use" }
57 }
58