| 1 |
// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -fobjc-exceptions -verify -Wfunction-effects %s |
| 2 |
|
| 3 |
#pragma clang diagnostic ignored "-Wperf-constraint-implies-noexcept" |
| 4 |
|
| 5 |
// Objective-C |
| 6 |
@interface OCClass |
| 7 |
- (void)method; |
| 8 |
@end |
| 9 |
|
| 10 |
void nb1(OCClass *oc) [[clang::nonblocking]] { |
| 11 |
[oc method]; // expected-warning {{function with 'nonblocking' attribute must not access ObjC methods or properties}} |
| 12 |
} |
| 13 |
void nb2(OCClass *oc) { |
| 14 |
[oc method]; // expected-note {{function cannot be inferred 'nonblocking' because it accesses an ObjC method or property}} |
| 15 |
} |
| 16 |
void nb3(OCClass *oc) [[clang::nonblocking]] { |
| 17 |
nb2(oc); // expected-warning {{function with 'nonblocking' attribute must not call non-'nonblocking' function 'nb2'}} |
| 18 |
} |
| 19 |
|
| 20 |
void nb4() [[clang::nonblocking]] { |
| 21 |
@try { |
| 22 |
@throw @"foo"; // expected-warning {{function with 'nonblocking' attribute must not throw or catch exceptions}} |
| 23 |
} |
| 24 |
@catch (...) { // expected-warning {{function with 'nonblocking' attribute must not throw or catch exceptions}} |
| 25 |
} |
| 26 |
@finally { // expected-warning {{function with 'nonblocking' attribute must not throw or catch exceptions}} |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
@class Lock; |
| 31 |
extern Lock *someLock; |
| 32 |
|
| 33 |
void nb5() [[clang::nonblocking]] { |
| 34 |
@autoreleasepool { // expected-warning {{function with 'nonblocking' attribute must not access ObjC methods or properties}} |
| 35 |
} |
| 36 |
|
| 37 |
@synchronized(someLock) { // expected-warning {{function with 'nonblocking' attribute must not access ObjC methods or properties}} |
| 38 |
} |
| 39 |
} |