gcc/testsuite/c-c++-common/Wdangling-else-4.c
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-Wdangling-else" } */ |
| 3 | |
| 4 | void bar (int); |
| 5 | |
| 6 | void |
| 7 | foo (int a, int b, int c) |
| 8 | { |
| 9 | if (a) /* { dg-warning "suggest explicit braces to avoid ambiguous .else." } */ |
| 10 | switch (b) |
| 11 | case 0: |
| 12 | if (c) |
| 13 | bar (1); |
| 14 | else |
| 15 | bar (2); |
| 16 | } |
| 17 | |
| 18 | void |
| 19 | baz (int a, int b, int c) |
| 20 | { |
| 21 | if (a) |
| 22 | switch (b) |
| 23 | { |
| 24 | case 0: |
| 25 | if (c) |
| 26 | bar (1); |
| 27 | } |
| 28 | else |
| 29 | bar (2); |
| 30 | } |
| 31 |