| 1 |
// RUN: %clang_cc1 -fsyntax-only -std=gnu89 -verify -Wimplicit-fallthrough %s |
| 2 |
// RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s |
| 3 |
// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s |
| 4 |
// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s |
| 5 |
// RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough %s |
| 6 |
|
| 7 |
int fallthrough_attribute_spelling(int n) { |
| 8 |
switch (n) { |
| 9 |
case 0: |
| 10 |
n++; |
| 11 |
case 1: |
| 12 |
#if defined(C2X) |
| 13 |
// expected-warning@-2{{unannotated fall-through between switch labels}} expected-note@-2{{insert '[[fallthrough]];' to silence this warning}} expected-note@-2{{insert 'break;' to avoid fall-through}} |
| 14 |
#else |
| 15 |
// expected-warning@-4{{unannotated fall-through between switch labels}} expected-note@-4{{insert '__attribute__((fallthrough));' to silence this warning}} expected-note@-4{{insert 'break;' to avoid fall-through}} |
| 16 |
#endif |
| 17 |
n++; |
| 18 |
__attribute__((fallthrough)); |
| 19 |
case 2: |
| 20 |
n++; |
| 21 |
break; |
| 22 |
} |
| 23 |
return n; |
| 24 |
} |