diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-01 23:12:55 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-01 23:12:55 +0000 |
commit | eff9a7ff9188f81812770549d329d0447702abdd (patch) | |
tree | eba5072b11f6500f46596d18b3785db2c8e99907 /clang/test/SemaCXX/array-bounds.cpp | |
parent | 98a3c80a3ebdca2379fab4ae225512bb1d20a3bd (diff) | |
download | bcm5719-llvm-eff9a7ff9188f81812770549d329d0447702abdd.tar.gz bcm5719-llvm-eff9a7ff9188f81812770549d329d0447702abdd.zip |
Teach CFGBuilder to prune trivially unreachable case statements.
llvm-svn: 126797
Diffstat (limited to 'clang/test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | clang/test/SemaCXX/array-bounds.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp index 20451bf2f2b..5db9c1f6c98 100644 --- a/clang/test/SemaCXX/array-bounds.cpp +++ b/clang/test/SemaCXX/array-bounds.cpp @@ -127,4 +127,23 @@ int test_sizeof_as_condition(int flag) { return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}} } +void test_switch() { + switch (4) { + case 1: { + int arr[2]; + arr[2] = 1; // no-warning + break; + } + case 4: { + int arr[2]; // expected-note {{array 'arr' declared here}} + arr[2] = 1; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}} + break; + } + default: { + int arr[2]; + arr[2] = 1; // no-warning + break; + } + } +} |