diff options
author | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
commit | 173a4f43a911175643bda81ee675e8d9269056ea (patch) | |
tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /test/SemaCXX/switch-implicit-fallthrough.cpp | |
parent | 88f7a7d5251a2d813460274c92decc143a11569b (diff) | |
download | FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz |
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'test/SemaCXX/switch-implicit-fallthrough.cpp')
-rw-r--r-- | test/SemaCXX/switch-implicit-fallthrough.cpp | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/test/SemaCXX/switch-implicit-fallthrough.cpp b/test/SemaCXX/switch-implicit-fallthrough.cpp index d795923..0bc43cd 100644 --- a/test/SemaCXX/switch-implicit-fallthrough.cpp +++ b/test/SemaCXX/switch-implicit-fallthrough.cpp @@ -229,6 +229,59 @@ int fallthrough_covered_enums(Enum e) { return n; } +// Fallthrough annotations in local classes used to generate "fallthrough +// annotation does not directly precede switch label" warning. +void fallthrough_in_local_class() { + class C { + void f(int x) { + switch (x) { + case 0: + x++; + [[clang::fallthrough]]; // no diagnostics + case 1: + x++; + default: // \ + expected-warning{{unannotated fall-through between switch labels}} \ + expected-note{{insert 'break;' to avoid fall-through}} + break; + } + } + }; +} + +// Fallthrough annotations in lambdas used to generate "fallthrough +// annotation does not directly precede switch label" warning. +void fallthrough_in_lambda() { + (void)[] { + int x = 0; + switch (x) { + case 0: + x++; + [[clang::fallthrough]]; // no diagnostics + case 1: + x++; + default: // \ + expected-warning{{unannotated fall-through between switch labels}} \ + expected-note{{insert 'break;' to avoid fall-through}} + break; + } + }; +} + +namespace PR18983 { + void fatal() __attribute__((noreturn)); + int num(); + void test() { + switch (num()) { + case 1: + fatal(); + // Don't issue a warning. + case 2: + break; + } + } +} + int fallthrough_targets(int n) { [[clang::fallthrough]]; // expected-error{{fallthrough annotation is outside switch statement}} @@ -247,21 +300,3 @@ int fallthrough_targets(int n) { } return n; } - -// Fallthrough annotations in local classes used to generate "fallthrough -// annotation does not directly precede switch label" warning. -void fallthrough_in_local_class() { - class C { - void f(int x) { - switch (x) { - case 0: - x++; - [[clang::fallthrough]]; // no diagnostics - case 1: - x++; - break; - } - } - }; -} - |