Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / Wimplicit-fallthrough-6.c
blob9593f670709efa4e878ce77a453a1cd880f06327
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wimplicit-fallthrough" } */
5 extern void bar (int);
7 /* Test nested scopes. */
9 void
10 f (int i)
12 switch (i)
14 case 1:
16 int j;
18 case 2:
19 bar (99);
22 switch (i)
24 case 1:
26 int j = 10; /* { dg-warning "statement may fall through" } */
28 case 2:
29 bar (99);
32 switch (i)
34 case 1:
36 int k = 9;
37 k++;
39 int j = 10;
40 j++; /* { dg-warning "statement may fall through" } */
43 case 2:
44 bar (99);
47 switch (i)
49 case 1:
51 int k = 9;
52 k++;
54 int j = 10;
55 j++;
57 bar (1); /* { dg-warning "statement may fall through" } */
61 case 2:
62 bar (99);
65 switch (i)
67 case 1:
69 int j = 0;
70 bar (j);
71 __attribute__((fallthrough));
73 case 2:
74 bar (99);
77 switch (i)
79 case 1:
81 int j = 0;
83 int k = j + 5;
84 bar (k);
85 __attribute__((fallthrough));
88 case 2:
89 bar (99);
92 switch (i)
94 case 1:
96 int j = 0;
97 bar (j);
98 return;
100 case 2:
101 bar (99);
104 switch (i)
106 case 1:
108 int j = 0;
109 bar (j);
110 goto L1;
113 case 2:
114 bar (99);
117 switch (i)
119 case 1:
120 { /* { dg-warning "statement may fall through" "" { target c } } */
121 int j = 0;
122 bar (j);
123 if (j == 8)
124 return;
125 } /* { dg-warning "statement may fall through" "" { target c++ } } */
126 case 2:
127 bar (99);
130 switch (i)
132 case 1:
134 int j = 0;
135 bar (j);
136 if (j == 8)
137 return;
138 else
139 return;
141 case 2:
142 bar (99);
145 switch (i)
147 case 1:
148 { /* { dg-warning "statement may fall through" "" { target c } } */
149 int j = 0;
150 bar (j);
151 if (j == 8)
152 bar (1);
153 else
154 return;
155 } /* { dg-warning "statement may fall through" "" { target c++ } } */
156 case 2:
157 bar (99);
160 switch (i)
162 case 1:
164 int j = 0;
165 bar (j);
166 if (j == 8)
167 return;
168 else
169 bar (2); /* { dg-warning "statement may fall through" } */
171 case 2:
172 bar (99);
175 switch (i)
177 case 1:
178 { /* { dg-warning "statement may fall through" "" { target c } } */
179 int j = 0;
180 bar (j);
181 if (j == 8)
182 bar (1);
183 else
184 bar (2);
185 } /* { dg-warning "statement may fall through" "" { target c++ } } */
186 case 2:
187 bar (99);
190 switch (i)
192 case 1:
194 int j = 0;
195 bar (j);
196 if (j == 8)
197 return;
199 break;
200 case 2:
201 bar (99);
204 switch (i)
206 case 1:
208 int j = 0;
209 bar (j);
210 if (j == 8)
211 return;
212 else
213 return;
215 break;
216 case 2:
217 bar (99);
220 switch (i)
222 case 1:
224 int j = 0;
225 bar (j);
226 if (j == 8)
227 bar (1);
228 else
229 return;
231 break;
232 case 2:
233 bar (99);
236 switch (i)
238 case 1:
240 int j = 0;
241 bar (j);
242 if (j == 8)
243 return;
244 else
245 bar (2);
247 break;
248 case 2:
249 bar (99);
252 switch (i)
254 case 1:
256 int j = 0;
257 bar (j);
258 if (j == 8)
259 bar (1);
260 else
261 bar (2);
263 break;
264 case 2:
265 bar (99);
268 switch (i)
270 case 1:
272 int j = 9;
273 while (1);
275 case 2:
276 bar (99);
279 switch (i)
281 case 1:
282 { /* { dg-warning "statement may fall through" "" { target c } } */
283 int j = 9;
284 switch (j);
285 } /* { dg-warning "statement may fall through" "" { target c++ } } */
286 case 2:
287 bar (99);
290 switch (i)
292 case 1:
294 int j = 0;
295 bar (j);
296 if (j == 8)
297 bar (1);
298 else
299 bar (2);
300 __attribute__((fallthrough));
302 case 2:
303 bar (99);