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 | 35c70f64db03b74f09846e8b38f5ba10cb84a32a (patch) | |
tree | 43f57e63e03fbe9727ed7488bfc251ef4d5116f8 /clang/test/SemaCXX/array-bounds.cpp | |
parent | 76e68ea916d13dfaf5e8f4feaab1d69fa0b5cc2b (diff) | |
download | bcm5719-llvm-35c70f64db03b74f09846e8b38f5ba10cb84a32a.tar.gz bcm5719-llvm-35c70f64db03b74f09846e8b38f5ba10cb84a32a.zip |
Teach CFGBuilder that the 'default' branch of a switch statement is dead if all enum values in a switch conditioned are handled.
llvm-svn: 127727
Diffstat (limited to 'clang/test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | clang/test/SemaCXX/array-bounds.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp index 62b4d520cc7..3bd6c35420d 100644 --- a/clang/test/SemaCXX/array-bounds.cpp +++ b/clang/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 +} |