| 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(size: 2); |
| 14 | printf(format: "ptr: %p\n" , ptr); // ensure we don't optimize out the malloc |
| 15 | } |
| 16 | |
| 17 | int main() { |
| 18 | printf(format: "Starting run\n" ); |
| 19 | violation(); |
| 20 | printf(format: "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 | |