[gn build] Port 0154dce8d39d
[llvm-project.git] / compiler-rt / test / rtsan / blocking_call.cpp
blob5c7f9d331096deab5462737b7400fa0a8a76684a
1 // RUN: %clangxx -fsanitize=realtime %s -o %t
2 // RUN: not %run %t 2>&1 | FileCheck %s
3 // UNSUPPORTED: ios
5 // Intent: Check that a function marked with [[clang::nonblocking]] cannot call a function that is blocking.
7 #include <stdio.h>
8 #include <stdlib.h>
10 void custom_blocking_function() [[clang::blocking]] {
11 printf("In blocking function\n");
14 void realtime_function() [[clang::nonblocking]] { custom_blocking_function(); }
15 void nonrealtime_function() { custom_blocking_function(); }
17 int main() {
18 nonrealtime_function();
19 realtime_function();
20 return 0;
23 // CHECK: ==ERROR: RealtimeSanitizer: blocking-call
24 // CHECK-NEXT: Call to blocking function `custom_blocking_function()` in real-time context!
25 // CHECK-NEXT: {{.*custom_blocking_function*}}
26 // CHECK-NEXT: {{.*realtime_function*}}
28 // should only occur once
29 // CHECK-NOT: ==ERROR: RealtimeSanitizer: blocking-call