summaryrefslogtreecommitdiff
path: root/test/msan/no_sanitize_memory_prop.cc
blob: bfd4194dd266beaa9c6a9c27c22466ed37b9f840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// RUN: %clangxx_msan -O0 %s -o %t && %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O1 %s -o %t && %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O2 %s -o %t && %run %t >%t.out 2>&1
// RUN: %clangxx_msan -O3 %s -o %t && %run %t >%t.out 2>&1

// Test that (no_sanitize_memory) functions DO NOT propagate shadow.

#include <stdlib.h>
#include <stdio.h>

__attribute__((noinline))
__attribute__((no_sanitize_memory))
int f(int x) {
  return x;
}

int main(void) {
  int x;
  int * volatile p = &x;
  int y = f(*p);
  if (y)
    exit(0);
  return 0;
}