[cfe-commits] r125781 - /cfe/trunk/test/SemaCXX/array-bounds.cpp

Ted Kremenek kremenek at apple.com
Thu Feb 17 13:40:51 PST 2011


Author: kremenek
Date: Thu Feb 17 15:40:51 2011
New Revision: 125781

URL: http://llvm.org/viewvc/llvm-project?rev=125781&view=rev
Log:
Add -Warray-bounds test showing how the warning currently interoperates with macros.

Modified:
    cfe/trunk/test/SemaCXX/array-bounds.cpp

Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=125781&r1=125780&r2=125781&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp Thu Feb 17 15:40:51 2011
@@ -74,3 +74,14 @@
 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)}}
+}
+





More information about the cfe-commits mailing list