blob: b8b87f4e7ef2977decea71644a85dbccca3d1f70 (
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
25
26
27
28
29
30
|
// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SANITIZED %s < %t.out
// RUN: %clang_tysan -DNOSAN -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-NOSAN %s < %t.out
// RUN: %clang -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SIMPLE %s < %t.out
#include <stdio.h>
#if __has_feature(type_sanitizer)
# ifdef NOSAN
__attribute__((no_sanitize("type")))
# endif
int main(){
int value = 42;
printf("As float: %f\n", *(float *)&value);
// CHECK-SANITIZED: ERROR: TypeSanitizer
// CHECK-NOSAN-NOT: ERROR: TypeSanitizer
return 0;
}
#else
int main() {
printf("Nothing interesting here\n");
return 0;
}
// CHECK-SIMPLE: Nothing interesting here
#endif
|