Evgeniy Stepanov | 021ba51 | 2013-02-28 11:25:54 +0000 | [diff] [blame] | 1 | // RUN: %clangxx_msan -m64 -O0 %s -o %t && %t >%t.out 2>&1 |
| 2 | // RUN: %clangxx_msan -m64 -O1 %s -o %t && not %t >%t.out 2>&1 |
| 3 | // RUN: FileCheck %s < %t.out |
| 4 | // RUN: %clangxx_msan -m64 -O2 %s -o %t && not %t >%t.out 2>&1 |
| 5 | // RUN: FileCheck %s < %t.out |
| 6 | // RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1 |
| 7 | // RUN: FileCheck %s < %t.out |
| 8 | |
| 9 | // Test that (no_sanitize_memory) functions propagate shadow. |
| 10 | |
| 11 | // Note that at -O0 there is no report, because 'x' in 'f' is spilled to the |
| 12 | // stack, and then loaded back as a fully initialiazed value (due to |
| 13 | // no_sanitize_memory attribute). |
| 14 | |
| 15 | #include <stdlib.h> |
| 16 | #include <stdio.h> |
| 17 | |
| 18 | __attribute__((noinline)) |
| 19 | __attribute__((no_sanitize_memory)) |
| 20 | int f(int x) { |
| 21 | return x; |
| 22 | } |
| 23 | |
| 24 | int main(void) { |
| 25 | int x; |
| 26 | int * volatile p = &x; |
| 27 | int y = f(*p); |
Evgeniy Stepanov | 6ac157d | 2013-05-28 14:27:30 +0000 | [diff] [blame^] | 28 | // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value |
Evgeniy Stepanov | 021ba51 | 2013-02-28 11:25:54 +0000 | [diff] [blame] | 29 | // CHECK: {{#0 0x.* in main .*no_sanitize_memory_prop.cc:}}[[@LINE+1]] |
| 30 | if (y) |
| 31 | exit(0); |
| 32 | return 0; |
| 33 | } |