summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-02-17 21:40:51 +0000
committerTed Kremenek <kremenek@apple.com>2011-02-17 21:40:51 +0000
commit48d9626055df18ab22ce07dea8880a5317d71e11 (patch)
tree5283f401e958e8cd8d4fdd8507dac7520ec96cc4 /clang
parent57d736fd46d54ef60c459678ede378e91e0c1d31 (diff)
downloadbcm5719-llvm-48d9626055df18ab22ce07dea8880a5317d71e11.tar.gz
bcm5719-llvm-48d9626055df18ab22ce07dea8880a5317d71e11.zip
Add -Warray-bounds test showing how the warning currently interoperates with macros.
llvm-svn: 125781
Diffstat (limited to 'clang')
-rw-r--r--clang/test/SemaCXX/array-bounds.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp
index 94973762a1c..8c22865e79d 100644
--- a/clang/test/SemaCXX/array-bounds.cpp
+++ b/clang/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)}}
+}
+
OpenPOWER on IntegriCloud