xref: /aosp_15_r20/external/clang/test/SemaObjC/synchronized.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*67e74705SXin Li
3*67e74705SXin Li@interface PBXTrackableTaskManager @end
4*67e74705SXin Li
5*67e74705SXin Li@implementation PBXTrackableTaskManager
6*67e74705SXin Li- (id) init { return 0; }
7*67e74705SXin Li- (void) unregisterTask:(id) task {
8*67e74705SXin Li  @synchronized (self) {
9*67e74705SXin Li  id taskID = [task taskIdentifier];  // expected-warning {{method '-taskIdentifier' not found (return type defaults to 'id')}}
10*67e74705SXin Li  }
11*67e74705SXin Li}
12*67e74705SXin Li@end
13*67e74705SXin Li
14*67e74705SXin Li
15*67e74705SXin Listruct x { int a; } b;
16*67e74705SXin Li
17*67e74705SXin Livoid test1() {
18*67e74705SXin Li  @synchronized (b) {  // expected-error {{@synchronized requires an Objective-C object type ('struct x' invalid)}}
19*67e74705SXin Li  }
20*67e74705SXin Li
21*67e74705SXin Li  @synchronized (42) {  // expected-error {{@synchronized requires an Objective-C object type ('int' invalid)}}
22*67e74705SXin Li  }
23*67e74705SXin Li}
24