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 | df26df726e9c5e7b54e5b53b9d2b87adcc82d909 (patch) | |
tree | 4238ce844f947f28c8b83e7117baec710c076ba2 /clang/test/SemaCXX/array-bounds.cpp | |
parent | 844cb50266ad0a8b85996c4ceb5af9fcd72f965b (diff) | |
download | bcm5719-llvm-df26df726e9c5e7b54e5b53b9d2b87adcc82d909.tar.gz bcm5719-llvm-df26df726e9c5e7b54e5b53b9d2b87adcc82d909.zip |
For C++, enhance -Warray-bounds to recursively analyze array subscript accesses in ?: expressions.
llvm-svn: 126766
Diffstat (limited to 'clang/test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | clang/test/SemaCXX/array-bounds.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp index 80646c71907..20451bf2f2b 100644 --- a/clang/test/SemaCXX/array-bounds.cpp +++ b/clang/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)}} +} + + |