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 | e71f3d587844110d836c82250830b27b1651afdb (patch) | |
tree | 732e9e5c56ba47ab23ff77d05a76e17c09cee8d4 /test/SemaCXX/array-bounds.cpp | |
parent | 8a04585eba8a87a660c9030c9cdef34c8c9f85c6 (diff) |
Teach CFGBuilder to prune trivially unreachable case statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126797 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | test/SemaCXX/array-bounds.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp index 20451bf2f2..5db9c1f6c9 100644 --- a/test/SemaCXX/array-bounds.cpp +++ b/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; + } + } +} |