PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / c-c++-common / Wimplicit-fallthrough-3.c
blobfbb97122ecb5ea39d5eed7644a770c6fcef0b896
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wimplicit-fallthrough" } */
5 extern void bar (int);
7 /* Test if with else. */
9 void
10 f (int i)
12 switch (i)
14 case 1:
15 if (i) /* { dg-warning "statement may fall through" } */
16 bar (1);
17 else
18 bar (2);
19 case 2:
20 __builtin_abort ();
23 switch (i)
25 case 1:
26 if (i)
27 bar (1);
28 else
29 bar (2);
30 bar (3); /* { dg-warning "statement may fall through" } */
31 case 2:
32 __builtin_abort ();
35 switch (i)
37 case 1:
38 if (i)
39 return;
40 else
41 bar (2); /* { dg-warning "statement may fall through" } */
42 case 2:
43 __builtin_abort ();
46 switch (i)
48 case 1:
49 if (i)
50 return;
51 else
52 bar (2);
53 bar (3); /* { dg-warning "statement may fall through" } */
54 case 2:
55 __builtin_abort ();
58 switch (i)
60 case 1:
61 if (i) /* { dg-warning "statement may fall through" } */
62 bar (1);
63 else
64 return;
65 case 2:
66 __builtin_abort ();
69 switch (i)
71 case 1:
72 if (i)
73 bar (1);
74 else
75 return;
76 bar (3); /* { dg-warning "statement may fall through" } */
77 case 2:
78 __builtin_abort ();
81 switch (i)
83 case 1:
84 if (i)
85 return;
86 else
87 return;
88 case 2:
89 __builtin_abort ();
92 switch (i)
94 case 1:
95 if (i)
96 return;
97 else
98 return;
99 bar (3); /* { dg-warning "statement may fall through" } */
100 case 2:
101 __builtin_abort ();
104 switch (i)
106 case 1:
107 if (i) /* { dg-warning "statement may fall through" } */
109 bar (1);
110 bar (2);
111 bar (3);
112 bar (4);
114 else
116 bar (5);
117 bar (6);
118 bar (7);
119 bar (8);
121 case 2:
122 __builtin_abort ();
125 switch (i)
127 case 1:
128 if (i)
130 bar (1);
131 bar (2);
132 bar (3);
133 bar (4);
135 else
137 bar (5);
138 bar (6);
139 bar (7);
140 bar (8);
142 bar (9); /* { dg-warning "statement may fall through" } */
143 case 2:
144 __builtin_abort ();
147 switch (i)
149 case 1:
150 if (i) /* { dg-warning "statement may fall through" } */
153 else
154 bar (2);
155 case 2:
156 __builtin_abort ();
159 switch (i)
161 case 1:
162 if (i) /* { dg-warning "statement may fall through" } */
163 bar (1);
164 else
167 case 2:
168 __builtin_abort ();
171 switch (i)
173 case 1:
174 if (i) /* { dg-warning "statement may fall through" } */
177 else
180 case 2:
181 __builtin_abort ();
184 switch (i)
186 case 1:
187 if (i) /* { dg-warning "statement may fall through" } */
188 return;
189 else
192 case 2:
193 __builtin_abort ();
196 switch (i)
198 case 1:
199 if (i) /* { dg-warning "statement may fall through" } */
202 else
203 return;
204 case 2:
205 __builtin_abort ();
208 switch (i)
210 case 1:
211 if (i)
212 goto L1;
213 else
214 bar (2); /* { dg-warning "statement may fall through" } */
215 case 2:
217 __builtin_abort ();
220 switch (i)
222 case 1:
223 if (i)
224 goto L2;
225 else
226 bar (2); /* { dg-warning "statement may fall through" } */
228 case 2:
229 __builtin_abort ();
232 switch (i)
234 case 1:
235 if (i) /* { dg-warning "statement may fall through" } */
236 bar (1);
237 else
238 goto L3;
239 case 2:
241 __builtin_abort ();
244 switch (i)
246 case 1:
247 if (i) /* { dg-warning "statement may fall through" } */
248 bar (1);
249 else
250 goto L4;
252 case 2:
253 __builtin_abort ();
256 switch (i)
258 case 1:
259 if (i)
260 goto L5;
261 else
262 goto L5;
264 case 2:
265 __builtin_abort ();
268 switch (i)
270 case 1:
271 if (i)
272 bar (1);
273 else
274 bar (2);
275 break;
276 case 2:
277 __builtin_abort ();
280 switch (i)
282 case 1:
283 if (i)
284 bar (1);
285 else
286 bar (2);
287 bar (3);
288 break;
289 case 2:
290 __builtin_abort ();
293 switch (i)
295 case 1:
296 if (i)
297 return;
298 else
299 bar (2);
300 break;
301 case 2:
302 __builtin_abort ();
305 switch (i)
307 case 1:
308 if (i)
309 return;
310 else
311 bar (2);
312 bar (3);
313 break;
314 case 2:
315 __builtin_abort ();
318 switch (i)
320 case 1:
321 if (i)
322 bar (1);
323 else
324 return;
325 break;
326 case 2:
327 __builtin_abort ();
330 switch (i)
332 case 1:
333 if (i)
334 bar (1);
335 else
336 return;
337 bar (3);
338 break;
339 case 2:
340 __builtin_abort ();
343 switch (i)
345 case 1:
346 if (i)
347 return;
348 else
349 return;
350 break;
351 case 2:
352 __builtin_abort ();
355 switch (i)
357 case 1:
358 if (i)
359 return;
360 else
361 return;
362 bar (3);
363 break;
364 case 2:
365 __builtin_abort ();
368 switch (i)
370 case 1:
371 if (i)
373 bar (1);
374 bar (2);
375 bar (3);
376 bar (4);
378 else
380 bar (5);
381 bar (6);
382 bar (7);
383 bar (8);
385 break;
386 case 2:
387 __builtin_abort ();
390 switch (i)
392 case 1:
393 if (i)
395 bar (1);
396 bar (2);
397 bar (3);
398 bar (4);
400 else
402 bar (5);
403 bar (6);
404 bar (7);
405 bar (8);
407 bar (9);
408 break;
409 case 2:
410 __builtin_abort ();
413 switch (i)
415 case 1:
416 if (i)
419 else
420 bar (2);
421 break;
422 case 2:
423 __builtin_abort ();
426 switch (i)
428 case 1:
429 if (i)
430 bar (1);
431 else
434 break;
435 case 2:
436 __builtin_abort ();
439 switch (i)
441 case 1:
442 if (i)
445 else
448 break;
449 case 2:
450 __builtin_abort ();
453 switch (i)
455 case 1:
456 if (i)
457 return;
458 else
461 break;
462 case 2:
463 __builtin_abort ();
466 switch (i)
468 case 1:
469 if (i)
472 else
473 return;
474 break;
475 case 2:
476 __builtin_abort ();
479 switch (i)
481 case 1:
482 if (i)
483 goto L6;
484 else
485 bar (2);
486 break;
487 case 2:
489 __builtin_abort ();
492 switch (i)
494 case 1:
495 if (i)
496 goto L7;
497 else
498 bar (2);
499 break;
501 case 2:
502 __builtin_abort ();
505 switch (i)
507 case 1:
508 if (i)
509 bar (1);
510 else
511 goto L8;
512 break;
513 case 2:
515 __builtin_abort ();
518 switch (i)
520 case 1:
521 if (i)
522 bar (1);
523 else
524 goto L9;
525 break;
527 case 2:
528 __builtin_abort ();
531 switch (i)
533 case 1:
534 if (i)
535 goto L10;
536 else
537 goto L10;
538 break;
539 L10:
540 case 2:
541 __builtin_abort ();