35 lines · cpp
1// RUN: %clangxx_msan -O0 %s -o %t && %run %t >%t.out 2>&12// RUN: %clangxx_msan -O1 %s -o %t && %run %t >%t.out 2>&13// RUN: %clangxx_msan -O2 %s -o %t && %run %t >%t.out 2>&14// RUN: %clangxx_msan -O3 %s -o %t && %run %t >%t.out 2>&15 6// RUN: %clangxx_msan -O0 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&17// RUN: %clangxx_msan -O1 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&18// RUN: %clangxx_msan -O2 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&19// RUN: %clangxx_msan -O3 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&110 11// Test that (no_sanitize_memory) functions12// * don't check shadow values (-DCHECK_IN_F)13// * treat all values loaded from memory as fully initialized (-UCHECK_IN_F)14 15#include <stdlib.h>16#include <stdio.h>17 18__attribute__((noinline))19__attribute__((no_sanitize_memory))20int f(void) {21 int x;22 int * volatile p = &x;23#ifdef CHECK_IN_F24 if (*p)25 exit(0);26#endif27 return *p;28}29 30int main(void) {31 if (f())32 exit(0);33 return 0;34}35