diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-02-23 01:52:07 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-02-23 01:52:07 +0000 |
commit | 477c8f5440f3bcacdc6548e7e41c5f2823ab6c87 (patch) | |
tree | aa78abb12c66bf19f1d117b00643594297942e76 /clang/test/SemaCXX/array-bounds.cpp | |
parent | 3427fac7c883efbb1097ac9ba13198b95c9fbccb (diff) | |
download | bcm5719-llvm-477c8f5440f3bcacdc6548e7e41c5f2823ab6c87.tar.gz bcm5719-llvm-477c8f5440f3bcacdc6548e7e41c5f2823ab6c87.zip |
Add test case for PR 9284, a false positive for -Warray-bounds that is now addressed using basic reachability analysis.
llvm-svn: 126291
Diffstat (limited to 'clang/test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | clang/test/SemaCXX/array-bounds.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp index ee7882daeaa..e82ce601389 100644 --- a/clang/test/SemaCXX/array-bounds.cpp +++ b/clang/test/SemaCXX/array-bounds.cpp @@ -90,15 +90,28 @@ int test_pr9240() { return array[(unsigned long long) 100]; // expected-warning {{array index of '100' indexes past the end of an array (that contains 100 elements)}} } +// PR 9284 - a template parameter can cause an array bounds access to be +// infeasible. template <bool extendArray> -void myFunc() { +void pr9284() { int arr[3 + (extendArray ? 1 : 0)]; if (extendArray) - arr[3] = 42; + arr[3] = 42; // no-warning } -void f() { - myFunc<false>(); +template <bool extendArray> +void pr9284b() { + int arr[3 + (extendArray ? 1 : 0)]; // expected-note {{array 'arr' declared here}} + + if (!extendArray) + arr[3] = 42; // expected-warning{{array index of '3' indexes past the end of an array (that contains 3 elements)}} +} + +void test_pr9284() { + pr9284<true>(); + pr9284<false>(); + pr9284b<true>(); + pr9284b<false>(); // expected-note{{in instantiation of function template specialization 'pr9284b<false>' requested here}} } |