1// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %run %t >%t.out 2>&1
2// FileCheck %s <%t.out
3// RUN: %clangxx_msan -m64 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
4// FileCheck %s <%t.out
5// RUN: %clangxx_msan -m64 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
6// FileCheck %s <%t.out
7
8// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1
9// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
10// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
11// FileCheck %s <%t.out
12// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
13// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
14// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=1 not %run %t >%t.out 2>&1
15// FileCheck %s <%t.out
16// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=0 not %run %t >%t.out 2>&1
17// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
18
19// Test behaviour of -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going.
20// -mllvm -msan-keep-going provides the default value of keep_going flag; value
21// of 1 can be overwritten by MSAN_OPTIONS, value of 0 can not.
22
23#include <stdio.h>
24#include <stdlib.h>
25
26int main(int argc, char **argv) {
27  char *volatile x = (char*)malloc(5 * sizeof(char));
28  if (x[0])
29    exit(0);
30  fprintf(stderr, "Done\n");
31  // CHECK-NOT: Done
32  // CHECK-KEEP-GOING: Done
33  return 0;
34}
35