diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-16 04:32:01 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-16 04:32:01 +0000 |
commit | 432c478fe0fec3946610d5dc7905daf5fbadf47b (patch) | |
tree | 848c91ec2a94d562d1226053e8ecc77c8cc572ef /test/SemaCXX/array-bounds.cpp | |
parent | a5bcb8fec45d127501cd70fe1654b5a08a8aeb35 (diff) |
Teach CFGBuilder that the 'default' branch of a switch statement is dead if all enum values in a switch conditioned are handled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | test/SemaCXX/array-bounds.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp index 62b4d520cc..3bd6c35420 100644 --- a/test/SemaCXX/array-bounds.cpp +++ b/test/SemaCXX/array-bounds.cpp @@ -160,3 +160,16 @@ void test_nested_switch() } } +// Test that if all the values of an enum covered, that the 'default' branch +// is unreachable. +enum Values { A, B, C, D }; +void test_all_enums_covered(enum Values v) { + int x[2]; + switch (v) { + case A: return; + case B: return; + case C: return; + case D: return; + } + x[2] = 0; // no-warning +} |