diff options
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Sema/fallthrough-attr.c | 24 | ||||
| -rw-r--r-- | clang/test/SemaCXX/switch-implicit-fallthrough.cpp | 12 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-unused-label-error.cpp | 8 |
3 files changed, 40 insertions, 4 deletions
diff --git a/clang/test/Sema/fallthrough-attr.c b/clang/test/Sema/fallthrough-attr.c new file mode 100644 index 00000000000..de50ebf39d4 --- /dev/null +++ b/clang/test/Sema/fallthrough-attr.c @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -std=gnu89 -verify -Wimplicit-fallthrough %s +// RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s +// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s +// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s +// RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough %s + +int fallthrough_attribute_spelling(int n) { + switch (n) { + case 0: + n++; + case 1: +#if defined(C2X) +// 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}} +#else +// 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}} +#endif + n++; + __attribute__((fallthrough)); + case 2: + n++; + break; + } + return n; +} diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough.cpp b/clang/test/SemaCXX/switch-implicit-fallthrough.cpp index 6ccac122cff..a67f6bef1f4 100644 --- a/clang/test/SemaCXX/switch-implicit-fallthrough.cpp +++ b/clang/test/SemaCXX/switch-implicit-fallthrough.cpp @@ -329,3 +329,15 @@ int fallthrough_alt_spelling(int n) { } return n; } + +int fallthrough_attribute_spelling(int n) { + switch (n) { + case 0: + n++; + __attribute__((fallthrough)); + case 1: + n++; + break; + } + return n; +} diff --git a/clang/test/SemaCXX/warn-unused-label-error.cpp b/clang/test/SemaCXX/warn-unused-label-error.cpp index 66b616f3cf2..461b1e8b963 100644 --- a/clang/test/SemaCXX/warn-unused-label-error.cpp +++ b/clang/test/SemaCXX/warn-unused-label-error.cpp @@ -18,9 +18,9 @@ namespace PR8455 { } void h() { - D: // expected-warning {{unused label 'D'}} - #pragma weak unused_local_static - __attribute__((unused)) // expected-warning {{declaration does not declare anything}} - ; + D: +#pragma weak unused_local_static + __attribute__((unused)) // expected-error {{'unused' attribute cannot be applied to a statement}} + ; } } |

