blob: 99f332de0ab62b660865471fe26cf5ea9eca9dc2 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %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}}
8typedef void * __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
9
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;
Fariborz Jahanian842f07b2010-03-30 22:40:11 +000017// rdar: // 7809460
Fariborz Jahanian9b2eb7b2011-11-29 01:48:40 +000018typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject;
19@property (nonatomic, retain) CGColorRefNoNSObject color;
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000020@end
21
22void setProperty(id self, id value) {
23 ((HandTested *)self)->x = value;
24}
25
26id getProperty(id self) {
27 return (id)((HandTested *)self)->x;
28}
29
30@implementation HandTested
31@synthesize x=x;
Fariborz Jahanian842f07b2010-03-30 22:40:11 +000032@dynamic color;
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000033@end
34
John McCall13591ed2009-07-25 04:36:53 +000035int main(int argc, char *argv[]) {
Fariborz Jahanianfa23c1d2009-01-13 23:34:40 +000036 HandTested *to;
37 to.x = tmp; // setter
38 if (tmp != to.x)
39 to.x = tmp;
40 return 0;
41}
42
Fariborz Jahanian9b2eb7b2011-11-29 01:48:40 +000043// rdar://10453342
44@interface I
45{
46 __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
47}
48@property (nonatomic, retain) __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}} \
49 // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
50@end
51void test_10453342() {
52 char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
53}
54