Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / c-c++-common / Wimplicit-fallthrough-7.c
bloba602216fa730f977edcfd9ef36000a9812d614ba
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-require-effective-target alloca } */
4 /* { dg-options "-Wimplicit-fallthrough" } */
6 extern void bar (int);
7 extern int bar2 (void);
8 extern int *map;
9 void
10 f (int i)
12 switch (i)
14 case 1:
15 bar (0); /* { dg-warning "statement may fall through" } */
16 static int i = 10;
17 case 2:
18 bar (99);
21 switch (i)
23 case 1:
24 { /* { dg-warning "statement may fall through" "" { target c } } */
25 int a[i]; /* { dg-warning "statement may fall through" "" { target c++ } } */
27 case 2:
28 bar (99);
31 switch (i)
33 case 1:
34 for (int j = 0; j < 10; j++) /* { dg-warning "statement may fall through" "" { target c } } */
35 map[j] = j; /* { dg-warning "statement may fall through" "" { target c++ } } */
36 case 2:
37 bar (99);
40 switch (i)
42 case 1:
44 bar (2);
45 while (--i); /* { dg-warning "statement may fall through" } */
46 case 2:
47 bar (99);
50 switch (i)
52 case 1:
54 switch (i + 2) /* { dg-warning "statement may fall through" } */
55 case 4:
56 bar (1);
57 case 5:
58 bar (5);
59 return;
61 case 2:
62 bar (99);
65 switch (i)
67 case 1:;
68 case 2:;
71 switch (i)
75 switch (i)
77 case 1:
78 if (i & 1) /* { dg-warning "statement may fall through" } */
80 bar (23);
81 break;
83 case 2:
84 bar (99);
87 switch (i)
89 case 1:
90 if (i > 9) /* { dg-warning "statement may fall through" } */
92 bar (9);
93 if (i == 10)
95 bar (10);
96 break;
99 case 2:
100 bar (99);
103 int r;
104 switch (i)
106 case 1:
107 r = bar2 ();
108 if (r) /* { dg-warning "statement may fall through" } */
109 break;
110 case 2:
111 bar (99);
114 switch (i)
116 case 1:
117 r = bar2 ();
118 if (r)
119 return;
120 if (!i) /* { dg-warning "statement may fall through" } */
121 return;
122 case 2:
123 bar (99);