aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/misc-ps-cxx0x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/misc-ps-cxx0x.cpp')
-rw-r--r--test/Analysis/misc-ps-cxx0x.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Analysis/misc-ps-cxx0x.cpp b/test/Analysis/misc-ps-cxx0x.cpp
index e840bb01d2..b00164ca47 100644
--- a/test/Analysis/misc-ps-cxx0x.cpp
+++ b/test/Analysis/misc-ps-cxx0x.cpp
@@ -45,3 +45,26 @@ int tempobj2()
return j; // no-warning
}
+
+
+// Test for correct handling of C++ ForRange statement.
+void test1() {
+ int array[2] = { 1, 2 };
+ int j = 0;
+ for ( int i : array )
+ j += i;
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+
+void test2() {
+ int array[2] = { 1, 2 };
+ int j = 0;
+ for (int i : array)
+ j += i;
+ if (j == 3)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+