xref: /llvm-project/clang/test/SemaObjC/attr-objc-NSObject.m (revision 3fefeafa49299ef924414bfa1b678e0f656b3618)
1// RUN: %clang_cc1 -verify -Wno-objc-root-class -fsyntax-only %s
2
3@interface NSArray<__covariant ObjectType>
4- (void)containsObject:(ObjectType)anObject; // expected-note {{passing argument to parameter 'anObject' here}}
5- (void)description;
6@end
7
8typedef __attribute__((NSObject)) struct Foo *FooRef;
9typedef struct Bar *BarRef;
10
11void good() {
12  FooRef object;
13  NSArray<FooRef> *array;
14  [array containsObject:object];
15  [object description];
16}
17
18void bad() {
19  BarRef object;
20  NSArray<BarRef> *array; // expected-error {{type argument 'BarRef' (aka 'struct Bar *') is neither an Objective-C object nor a block type}}
21  [array containsObject:object]; // expected-warning {{incompatible pointer types sending 'BarRef' (aka 'struct Bar *') to parameter of type 'id'}}
22  [object description]; // expected-warning {{receiver type 'BarRef' (aka 'struct Bar *') is not 'id' or interface pointer, consider casting it to 'id'}}
23}
24