diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-01 18:41:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-01 18:41:00 +0000 |
commit | 3aea4dac830cb03d883a13ab30c28a3a53beca58 (patch) | |
tree | 9bf4f73c8a61de06421787a085df0243de518685 /test/SemaCXX/array-bounds.cpp | |
parent | 9e876876afc13aa671cc11a17c19907c599b9ab9 (diff) |
For C++, enhance -Warray-bounds to recursively analyze array subscript accesses in ?: expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126766 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | test/SemaCXX/array-bounds.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp index 80646c7190..20451bf2f2 100644 --- a/test/SemaCXX/array-bounds.cpp +++ b/test/SemaCXX/array-bounds.cpp @@ -120,3 +120,11 @@ int test_pr9296() { return array[true]; // no-warning } +int test_sizeof_as_condition(int flag) { + int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}} + if (flag) + return sizeof(char) != sizeof(char) ? arr[2] : arr[1]; + 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)}} +} + + |