gcc/testsuite/gcc.dg/c23-attr-fallthrough-6.c
raw| 1 | /* Test C23 attribute syntax. Invalid use of fallthrough attribute in |
| 2 | bad context inside switch. */ |
| 3 | /* { dg-do compile } */ |
| 4 | /* { dg-options "-std=c23 -pedantic-errors -Wextra" } */ |
| 5 | |
| 6 | int |
| 7 | f (int a) |
| 8 | { |
| 9 | switch (a) |
| 10 | { |
| 11 | case 1: |
| 12 | a++; |
| 13 | [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */ |
| 14 | a++; |
| 15 | [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */ |
| 16 | } |
| 17 | return a; |
| 18 | } |