gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C
raw| 1 | // PR c++/77803 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | // { dg-options "-Wimplicit-fallthrough" } |
| 4 | |
| 5 | struct A {}; |
| 6 | int a; |
| 7 | |
| 8 | void |
| 9 | fn1 () |
| 10 | { |
| 11 | switch (0) { |
| 12 | case 0: |
| 13 | { |
| 14 | A b; |
| 15 | [[fallthrough]]; |
| 16 | } |
| 17 | default: |
| 18 | a = 0; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | void |
| 23 | fn2 () |
| 24 | { |
| 25 | switch (0) { |
| 26 | case 0: |
| 27 | { |
| 28 | A b; |
| 29 | } // { dg-warning "statement may fall through" } |
| 30 | default: |
| 31 | a = 0; |
| 32 | } |
| 33 | } |