1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef;
4typedef struct CGColor * __attribute__((NSObject(12))) Illegal;  // expected-error {{'NSObject' attribute takes no arguments}}
5
6static int count;
7static CGColorRef tmp = 0;
8
9typedef struct S1  __attribute__ ((NSObject)) CGColorRef1; // expected-error {{'NSObject' attribute is for pointer types only}}
10typedef void *  __attribute__ ((NSObject)) CGColorRef2; // no-warning
11typedef void * CFTypeRef;
12
13@interface HandTested {
14@public
15    CGColorRef x;
16}
17
18@property(copy) CGColorRef x;
19// rdar://problem/7809460
20typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning
21@property (nonatomic, retain) CGColorRefNoNSObject color;
22// rdar://problem/12197822
23@property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning
24//rdar://problem/27747154
25@property (strong, nullable) CGColorRefNoNSObject color2; // no-warning
26@end
27
28void setProperty(id self, id value)  {
29  ((HandTested *)self)->x = value;
30}
31
32id getProperty(id self) {
33     return (id)((HandTested *)self)->x;
34}
35
36@implementation HandTested
37@synthesize x=x;
38@synthesize myObj;
39@dynamic color;
40@end
41
42int main(int argc, char *argv[]) {
43    HandTested *to;
44    to.x = tmp;  // setter
45    if (tmp != to.x)
46      to.x = tmp;
47    return 0;
48}
49
50// rdar://10453342
51@interface I
52{
53   __attribute__((NSObject)) void * color; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}}
54}
55  // <rdar://problem/10930507>
56@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning
57@end
58void test_10453342() {
59    char* __attribute__((NSObject)) string2 = 0; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}}
60}
61
62// rdar://11569860
63@interface A { int i; }
64@property(retain) __attribute__((NSObject)) int i; // expected-error {{'NSObject' attribute is for pointer types only}} \
65  						   // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
66@end
67
68@implementation A
69@synthesize i;
70@end
71
72