]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/msan/heap-origin.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / msan / heap-origin.cc
CommitLineData
92a42be0 1// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc 2// RUN: FileCheck %s < %t.out
92a42be0 3// RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc 4// RUN: FileCheck %s < %t.out
92a42be0 5// RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc 6// RUN: FileCheck %s < %t.out
92a42be0 7// RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc
JJ
8// RUN: FileCheck %s < %t.out
9
92a42be0 10// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc 11// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
92a42be0 12// RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc 13// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
92a42be0 14// RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc 15// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
92a42be0 16// RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1
1a4d82fc
JJ
17// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
18
19#include <stdlib.h>
20int main(int argc, char **argv) {
21 char *volatile x = (char*)malloc(5 * sizeof(char));
22 return *x;
23 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
24 // CHECK: {{#0 0x.* in main .*heap-origin.cc:}}[[@LINE-2]]
25
26 // CHECK-ORIGINS: Uninitialized value was created by a heap allocation
27 // CHECK-ORIGINS: {{#0 0x.* in .*malloc}}
28 // CHECK-ORIGINS: {{#1 0x.* in main .*heap-origin.cc:}}[[@LINE-7]]
29
30 // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*heap-origin.cc:.* main}}
31}