blob: b794eafc9ed7926e2dc309a298049a8e390132c9 [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +00002
3typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef;
4static int count;
5static CGColorRef tmp = 0;
6
7typedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
Ted Kremenek9af91222012-08-29 22:54:47 +00008typedef void * __attribute__ ((NSObject)) CGColorRef2; // no-warning
9typedef void * CFTypeRef;
Fariborz Jahanian842f07b2010-03-30 22:40:11 +000010
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000011@interface HandTested {
12@public
13 CGColorRef x;
14}
Fariborz Jahanian842f07b2010-03-30 22:40:11 +000015
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000016@property(copy) CGColorRef x;
Ted Kremenek9af91222012-08-29 22:54:47 +000017// rdar://problem/7809460
18typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning
Fariborz Jahanian9b2eb7b2011-11-29 01:48:40 +000019@property (nonatomic, retain) CGColorRefNoNSObject color;
Ted Kremenek9af91222012-08-29 22:54:47 +000020// rdar://problem/12197822
21@property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000022@end
23
24void setProperty(id self, id value) {
25 ((HandTested *)self)->x = value;
26}
27
28id getProperty(id self) {
29 return (id)((HandTested *)self)->x;
30}
31
32@implementation HandTested
33@synthesize x=x;
Ted Kremenek97573772012-08-30 00:27:25 +000034@synthesize myObj;
Fariborz Jahanian842f07b2010-03-30 22:40:11 +000035@dynamic color;
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000036@end
37
John McCall13591ed2009-07-25 04:36:53 +000038int main(int argc, char *argv[]) {
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000039 HandTested *to;
40 to.x = tmp; // setter
41 if (tmp != to.x)
42 to.x = tmp;
43 return 0;
44}
45
Fariborz Jahanian9b2eb7b2011-11-29 01:48:40 +000046// rdar://10453342
47@interface I
48{
49 __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
50}
Ted Kremenekf6e88d72012-03-01 01:40:32 +000051 // <rdar://problem/10930507>
Fariborz Jahanian34276822012-05-31 23:18:32 +000052@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning
Fariborz Jahanian9b2eb7b2011-11-29 01:48:40 +000053@end
54void test_10453342() {
55 char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
56}
57
Fariborz Jahanian34276822012-05-31 23:18:32 +000058// rdar://11569860
59@interface A { int i; }
60@property(retain) __attribute__((NSObject)) int i; // expected-error {{__attribute ((NSObject)) is for pointer types only}} \
61 // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
62@end
63
64@implementation A
65@synthesize i;
66@end
67