Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 2 | |
| 3 | typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef; |
| 4 | static int count; |
| 5 | static CGColorRef tmp = 0; |
| 6 | |
| 7 | typedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{__attribute ((NSObject)) is for pointer types only}} |
Ted Kremenek | 9af9122 | 2012-08-29 22:54:47 +0000 | [diff] [blame] | 8 | typedef void * __attribute__ ((NSObject)) CGColorRef2; // no-warning |
| 9 | typedef void * CFTypeRef; |
Fariborz Jahanian | 842f07b | 2010-03-30 22:40:11 +0000 | [diff] [blame] | 10 | |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 11 | @interface HandTested { |
| 12 | @public |
| 13 | CGColorRef x; |
| 14 | } |
Fariborz Jahanian | 842f07b | 2010-03-30 22:40:11 +0000 | [diff] [blame] | 15 | |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 16 | @property(copy) CGColorRef x; |
Ted Kremenek | 9af9122 | 2012-08-29 22:54:47 +0000 | [diff] [blame] | 17 | // rdar://problem/7809460 |
| 18 | typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 19 | @property (nonatomic, retain) CGColorRefNoNSObject color; |
Ted Kremenek | 9af9122 | 2012-08-29 22:54:47 +0000 | [diff] [blame] | 20 | // rdar://problem/12197822 |
| 21 | @property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 22 | @end |
| 23 | |
| 24 | void setProperty(id self, id value) { |
| 25 | ((HandTested *)self)->x = value; |
| 26 | } |
| 27 | |
| 28 | id getProperty(id self) { |
| 29 | return (id)((HandTested *)self)->x; |
| 30 | } |
| 31 | |
| 32 | @implementation HandTested |
| 33 | @synthesize x=x; |
Ted Kremenek | 9757377 | 2012-08-30 00:27:25 +0000 | [diff] [blame] | 34 | @synthesize myObj; |
Fariborz Jahanian | 842f07b | 2010-03-30 22:40:11 +0000 | [diff] [blame] | 35 | @dynamic color; |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 36 | @end |
| 37 | |
John McCall | 13591ed | 2009-07-25 04:36:53 +0000 | [diff] [blame] | 38 | int main(int argc, char *argv[]) { |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 39 | HandTested *to; |
| 40 | to.x = tmp; // setter |
| 41 | if (tmp != to.x) |
| 42 | to.x = tmp; |
| 43 | return 0; |
| 44 | } |
| 45 | |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 46 | // 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 Kremenek | f6e88d7 | 2012-03-01 01:40:32 +0000 | [diff] [blame] | 51 | // <rdar://problem/10930507> |
Fariborz Jahanian | 3427682 | 2012-05-31 23:18:32 +0000 | [diff] [blame] | 52 | @property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 53 | @end |
| 54 | void 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 Jahanian | 3427682 | 2012-05-31 23:18:32 +0000 | [diff] [blame] | 58 | // 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 | |