1 // RUN: %clangxx -fsanitize=realtime %s -o %t 2 // RUN: not %run %t 2>&1 | FileCheck %s 3 // UNSUPPORTED: ios 4 5 // Intent: Check that a function marked with [[clang::nonblocking]] cannot call a function that is blocking. 6 7 #include <stdio.h> 8 #include <stdlib.h> 9 10 void custom_blocking_function() [[clang::blocking]] { 11 printf("In blocking function\n"); 12 } 13 14 void realtime_function() [[clang::nonblocking]] { custom_blocking_function(); } 15 void nonrealtime_function() { custom_blocking_function(); } 16 17 int main() { 18 nonrealtime_function(); 19 realtime_function(); 20 return 0; 21 } 22 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*}} 27 28 // should only occur once 29 // CHECK-NOT: ==ERROR: RealtimeSanitizer: blocking-call 30