brintos

brintos / llvm-project-archived public Read only

0
0
Text · 757 B · b8b87f4 Raw
31 lines · c
1// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SANITIZED %s < %t.out2// RUN: %clang_tysan -DNOSAN -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-NOSAN %s < %t.out3// RUN: %clang -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SIMPLE %s < %t.out4 5#include <stdio.h>6 7#if __has_feature(type_sanitizer)8 9#  ifdef NOSAN10__attribute__((no_sanitize("type")))11#  endif12int main(){13 14  int value = 42;15  printf("As float: %f\n", *(float *)&value);16  // CHECK-SANITIZED: ERROR: TypeSanitizer17  // CHECK-NOSAN-NOT: ERROR: TypeSanitizer18 19  return 0;20}21 22#else23 24int main() {25  printf("Nothing interesting here\n");26  return 0;27}28// CHECK-SIMPLE: Nothing interesting here29 30#endif31