summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/msan/loop-scope.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/test/msan/loop-scope.cpp')
-rw-r--r--compiler-rt/test/msan/loop-scope.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler-rt/test/msan/loop-scope.cpp b/compiler-rt/test/msan/loop-scope.cpp
new file mode 100644
index 00000000000..638bdbe1732
--- /dev/null
+++ b/compiler-rt/test/msan/loop-scope.cpp
@@ -0,0 +1,18 @@
+// RUN: %clangxx_msan -O2 %s -o %t && \
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+#include <stdlib.h>
+
+int *p;
+
+int main() {
+ for (int i = 0; i < 3; i++) {
+ int x;
+ if (i == 0)
+ x = 0;
+ p = &x;
+ }
+ return *p; // BOOM
+ // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
+ // CHECK: #0 0x{{.*}} in main {{.*}}loop-scope.cpp:[[@LINE-2]]
+}
OpenPOWER on IntegriCloud