1 | // RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SANITIZED %s < %t.out |
2 | // RUN: %clang_tysan -DNOSAN -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-NOSAN %s < %t.out |
3 | // RUN: %clang -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SIMPLE %s < %t.out |
4 | |
5 | #include <stdio.h> |
6 | |
7 | #if __has_feature(type_sanitizer) |
8 | |
9 | # ifdef NOSAN |
10 | __attribute__((no_sanitize("type" ))) |
11 | # endif |
12 | int main(){ |
13 | |
14 | int value = 42; |
15 | printf("As float: %f\n" , *(float *)&value); |
16 | // CHECK-SANITIZED: ERROR: TypeSanitizer |
17 | // CHECK-NOSAN-NOT: ERROR: TypeSanitizer |
18 | |
19 | return 0; |
20 | } |
21 | |
22 | #else |
23 | |
24 | int main() { |
25 | printf(format: "Nothing interesting here\n" ); |
26 | return 0; |
27 | } |
28 | // CHECK-SIMPLE: Nothing interesting here |
29 | |
30 | #endif |
31 | |