xref: /llvm-project/compiler-rt/test/msan/no_sanitize_memory_prop.cpp (revision 15805c030f31b8d112ee4a4706ff4f5725c794df)
1 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t >%t.out 2>&1
2 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O1 %s -o %t && %run %t >%t.out 2>&1
3 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O2 %s -o %t && %run %t >%t.out 2>&1
4 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O3 %s -o %t && %run %t >%t.out 2>&1
5 
6 // Test that (no_sanitize_memory) functions DO NOT propagate shadow.
7 
8 #include <stdlib.h>
9 #include <stdio.h>
10 
11 __attribute__((noinline))
12 __attribute__((weak))
13 __attribute__((no_sanitize_memory))
f(int x)14 int f(int x) {
15   return x;
16 }
17 
main(void)18 int main(void) {
19   int x;
20   int * volatile p = &x;
21   int y = f(*p);
22   if (y)
23     exit(0);
24   return 0;
25 }
26