diff options
Diffstat (limited to 'test/SemaCXX/switch-implicit-fallthrough.cpp')
-rw-r--r-- | test/SemaCXX/switch-implicit-fallthrough.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/test/SemaCXX/switch-implicit-fallthrough.cpp b/test/SemaCXX/switch-implicit-fallthrough.cpp index 0bc43cdbd45b2..9540b1ff28808 100644 --- a/test/SemaCXX/switch-implicit-fallthrough.cpp +++ b/test/SemaCXX/switch-implicit-fallthrough.cpp @@ -179,18 +179,15 @@ void fallthrough_cfgblock_with_null_successor(int x) { int fallthrough_position(int n) { switch (n) { - [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} n += 300; [[clang::fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}} case 221: - [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} return 1; [[clang::fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}} case 222: - [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} n += 400; case 223: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} - [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} + ; } long p = static_cast<long>(n) * n; @@ -282,6 +279,23 @@ namespace PR18983 { } } +int fallthrough_placement_error(int n) { + switch (n) { + [[clang::fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}} + n += 300; + case 221: + [[clang::fallthrough]]; // expected-error{{fallthrough annotation does not directly precede switch label}} + return 1; + case 222: + [[clang::fallthrough]]; // expected-error{{fallthrough annotation does not directly precede switch label}} + n += 400; + [[clang::fallthrough]]; + case 223: + [[clang::fallthrough]]; // expected-error{{fallthrough annotation does not directly precede switch label}} + } + return n; +} + int fallthrough_targets(int n) { [[clang::fallthrough]]; // expected-error{{fallthrough annotation is outside switch statement}} |