1*d21b3d34SFangrui Song // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
2*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out
3*d21b3d34SFangrui Song // RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&1
4*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out
5*d21b3d34SFangrui Song // RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&1
6*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out
7*d21b3d34SFangrui Song // RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&1
8*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out
9*d21b3d34SFangrui Song 
10*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1
11*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
12*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t >%t.out 2>&1
13*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
14*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&1
15*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
16*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1
17*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
18*d21b3d34SFangrui Song 
19*d21b3d34SFangrui Song #include <stdlib.h>
main(int argc,char ** argv)20*d21b3d34SFangrui Song int main(int argc, char **argv) {
21*d21b3d34SFangrui Song   int x;
22*d21b3d34SFangrui Song   int *volatile p = &x;
23*d21b3d34SFangrui Song   return *p;
24*d21b3d34SFangrui Song   // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
25*d21b3d34SFangrui Song   // CHECK: {{#0 0x.* in main .*stack-origin.cpp:}}[[@LINE-2]]
26*d21b3d34SFangrui Song 
27*d21b3d34SFangrui Song   // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
28*d21b3d34SFangrui Song   // CHECK-ORIGINS: {{#0 0x.* in main .*stack-origin.cpp:}}[[@LINE-8]]
29*d21b3d34SFangrui Song 
30*d21b3d34SFangrui Song   // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin.cpp:.* main}}
31*d21b3d34SFangrui Song }
32