xref: /llvm-project/compiler-rt/test/rtsan/inactive.cpp (revision ca95bee649724a6092989076322daa501a0a6594)
1 // RUN: %clangxx %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s
3 // UNSUPPORTED: ios
4 
5 // Intent: Ensure [[clang::nonblocking]] has no impact if -fsanitize=realtime is not used
6 
7 #include <stdio.h>
8 #include <stdlib.h>
9 
10 // In this test, we don't use the -fsanitize=realtime flag, so nothing
11 // should happen here
12 void violation() [[clang::nonblocking]] {
13   void *ptr = malloc(2);
14   printf("ptr: %p\n", ptr); // ensure we don't optimize out the malloc
15 }
16 
17 int main() {
18   printf("Starting run\n");
19   violation();
20   printf("No violations ended the program\n");
21   return 0;
22   // CHECK: {{.*Starting run.*}}
23   // CHECK NOT: {{.*Real-time violation.*}}
24   // CHECK NOT: {{.*malloc*}}
25   // CHECK: {{.*No violations ended the program.*}}
26 }
27