diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-02-17 21:40:51 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-02-17 21:40:51 +0000 |
commit | a85f5284c34f3969701a6f2121e8fcfc2fc5e81d (patch) | |
tree | 3aa7ae841430b5c0bcf843ee733bac0f2325403b /test/SemaCXX/array-bounds.cpp | |
parent | 2d67b90a21c9c1093e6598809c2cbc832919cfe6 (diff) |
Add -Warray-bounds test showing how the warning currently interoperates with macros.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | test/SemaCXX/array-bounds.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp index 94973762a1..8c22865e79 100644 --- a/test/SemaCXX/array-bounds.cpp +++ b/test/SemaCXX/array-bounds.cpp @@ -74,3 +74,14 @@ template <int I> void f() { void test_templates() { f<5>(); // expected-note {{in instantiation}} } + +#define SIZE 10 +#define ARR_IN_MACRO(flag, arr, idx) flag ? arr[idx] : 1 + +int test_no_warn_macro_unreachable() { + int arr[SIZE]; // expected-note 2 {{array 'arr' declared here}} + // FIXME: We don't want to warn for the first case. + return ARR_IN_MACRO(0, arr, SIZE) + // expected-warning{{array index of '10' indexes past the end of an array (that contains 10 elements)}} + ARR_IN_MACRO(1, arr, SIZE); // expected-warning{{array index of '10' indexes past the end of an array (that contains 10 elements)}} +} + |