gcc/testsuite/c-c++-common/Wimplicit-fallthrough-12.c
raw| 1 | /* PR c/7652 */ |
| 2 | /* { dg-do compile } */ |
| 3 | /* { dg-options "-Wimplicit-fallthrough -O2" } */ |
| 4 | |
| 5 | /* Don't let optimizations preclude the warning. */ |
| 6 | |
| 7 | extern void bar (int); |
| 8 | |
| 9 | void |
| 10 | f (int i) |
| 11 | { |
| 12 | switch (i) |
| 13 | { |
| 14 | case 1: |
| 15 | if (i > 1) |
| 16 | bar (1); |
| 17 | else |
| 18 | goto D; |
| 19 | break; |
| 20 | case 2: |
| 21 | bar (2); /* { dg-warning "statement may fall through" } */ |
| 22 | D: |
| 23 | default: |
| 24 | bar (33); |
| 25 | } |
| 26 | } |