summaryrefslogtreecommitdiff
path: root/test/msan/no_sanitize_memory_prop.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/msan/no_sanitize_memory_prop.cc')
-rw-r--r--test/msan/no_sanitize_memory_prop.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/msan/no_sanitize_memory_prop.cc b/test/msan/no_sanitize_memory_prop.cc
new file mode 100644
index 0000000000000..4275ebbf78e1f
--- /dev/null
+++ b/test/msan/no_sanitize_memory_prop.cc
@@ -0,0 +1,24 @@
+// RUN: %clangxx_msan -m64 -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O1 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O2 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O3 %s -o %t && %run %t >%t.out 2>&1
+
+// Test that (no_sanitize_memory) functions DO NOT propagate shadow.
+
+#include <stdlib.h>
+#include <stdio.h>
+
+__attribute__((noinline))
+__attribute__((no_sanitize_memory))
+int f(int x) {
+ return x;
+}
+
+int main(void) {
+ int x;
+ int * volatile p = &x;
+ int y = f(*p);
+ if (y)
+ exit(0);
+ return 0;
+}