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; |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 4 | typedef struct CGColor * __attribute__((NSObject(12))) Illegal; // expected-error {{'NSObject' attribute takes no arguments}} |
Aaron Ballman | 081c883 | 2013-07-23 12:13:14 +0000 | [diff] [blame] | 5 | |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 6 | static int count; |
| 7 | static CGColorRef tmp = 0; |
| 8 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 9 | typedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{'NSObject' attribute is for pointer types only}} |
Ted Kremenek | 9af9122 | 2012-08-29 22:54:47 +0000 | [diff] [blame] | 10 | typedef void * __attribute__ ((NSObject)) CGColorRef2; // no-warning |
| 11 | typedef void * CFTypeRef; |
Fariborz Jahanian | 842f07b | 2010-03-30 22:40:11 +0000 | [diff] [blame] | 12 | |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 13 | @interface HandTested { |
| 14 | @public |
| 15 | CGColorRef x; |
| 16 | } |
Fariborz Jahanian | 842f07b | 2010-03-30 22:40:11 +0000 | [diff] [blame] | 17 | |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 18 | @property(copy) CGColorRef x; |
Ted Kremenek | 9af9122 | 2012-08-29 22:54:47 +0000 | [diff] [blame] | 19 | // rdar://problem/7809460 |
| 20 | typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 21 | @property (nonatomic, retain) CGColorRefNoNSObject color; |
Ted Kremenek | 9af9122 | 2012-08-29 22:54:47 +0000 | [diff] [blame] | 22 | // rdar://problem/12197822 |
| 23 | @property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 24 | @end |
| 25 | |
| 26 | void setProperty(id self, id value) { |
| 27 | ((HandTested *)self)->x = value; |
| 28 | } |
| 29 | |
| 30 | id getProperty(id self) { |
| 31 | return (id)((HandTested *)self)->x; |
| 32 | } |
| 33 | |
| 34 | @implementation HandTested |
| 35 | @synthesize x=x; |
Ted Kremenek | 9757377 | 2012-08-30 00:27:25 +0000 | [diff] [blame] | 36 | @synthesize myObj; |
Fariborz Jahanian | 842f07b | 2010-03-30 22:40:11 +0000 | [diff] [blame] | 37 | @dynamic color; |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 38 | @end |
| 39 | |
John McCall | 13591ed | 2009-07-25 04:36:53 +0000 | [diff] [blame] | 40 | int main(int argc, char *argv[]) { |
Fariborz Jahanian | fa23c1d | 2009-01-13 23:34:40 +0000 | [diff] [blame] | 41 | HandTested *to; |
| 42 | to.x = tmp; // setter |
| 43 | if (tmp != to.x) |
| 44 | to.x = tmp; |
| 45 | return 0; |
| 46 | } |
| 47 | |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 48 | // rdar://10453342 |
| 49 | @interface I |
| 50 | { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 51 | __attribute__((NSObject)) void * color; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}} |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 52 | } |
Ted Kremenek | f6e88d7 | 2012-03-01 01:40:32 +0000 | [diff] [blame] | 53 | // <rdar://problem/10930507> |
Fariborz Jahanian | 3427682 | 2012-05-31 23:18:32 +0000 | [diff] [blame] | 54 | @property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 55 | @end |
| 56 | void test_10453342() { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 57 | char* __attribute__((NSObject)) string2 = 0; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}} |
Fariborz Jahanian | 9b2eb7b | 2011-11-29 01:48:40 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Fariborz Jahanian | 3427682 | 2012-05-31 23:18:32 +0000 | [diff] [blame] | 60 | // rdar://11569860 |
| 61 | @interface A { int i; } |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 62 | @property(retain) __attribute__((NSObject)) int i; // expected-error {{'NSObject' attribute is for pointer types only}} \ |
Fariborz Jahanian | 3427682 | 2012-05-31 23:18:32 +0000 | [diff] [blame] | 63 | // expected-error {{property with 'retain (or strong)' attribute must be of object type}} |
| 64 | @end |
| 65 | |
| 66 | @implementation A |
| 67 | @synthesize i; |
| 68 | @end |
| 69 | |