23 lines · cpp
1// RUN: %clangxx -fsanitize=realtime %s -o %t2// RUN: not %run %t 2>&1 | FileCheck %s3// UNSUPPORTED: ios4 5// Intent: Ensure that an intercepted call in a [[clang::nonblocking]] function6// is flagged as an error. Basic smoke test.7 8#include <stdio.h>9#include <stdlib.h>10 11void violation() [[clang::nonblocking]] {12 void *ptr = malloc(2);13 printf("ptr: %p\n", ptr); // ensure we don't optimize out the malloc14}15 16int main() {17 violation();18 return 0;19 // CHECK: ==ERROR: RealtimeSanitizer: unsafe-library-call20 // CHECK-NEXT: Intercepted call to real-time unsafe function `malloc` in real-time context!21 // CHECK-NEXT: {{.*malloc*}}22}23