Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 2 | |
| 3 | // Check property attribute consistency. |
| 4 | |
| 5 | @interface I0 |
| 6 | @property(readonly, readwrite) int p0; // expected-error {{property attributes 'readonly' and 'readwrite' are mutually exclusive}} |
| 7 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 8 | @property(retain) int p1; // expected-error {{property with 'retain (or strong)' attribute must be of object type}} |
| 9 | @property(strong) int s1; // expected-error {{property with 'retain (or strong)' attribute must be of object type}} |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 10 | |
| 11 | @property(copy) int p2; // expected-error {{property with 'copy' attribute must be of object type}} |
| 12 | |
| 13 | @property(assign, copy) id p3_0; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}} |
| 14 | @property(assign, retain) id p3_1; // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 15 | @property(assign, strong) id s3_1; // expected-error {{property attributes 'assign' and 'strong' are mutually exclusive}} |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 16 | @property(copy, retain) id p3_2; // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 17 | @property(copy, strong) id s3_2; // expected-error {{property attributes 'copy' and 'strong' are mutually exclusive}} |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 18 | @property(assign, copy, retain) id p3_3; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 19 | @property(assign, copy, strong) id s3_3; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'assign' and 'strong' are mutually exclusive}} |
| 20 | |
| 21 | @property(unsafe_unretained, copy) id p4_0; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}} |
| 22 | @property(unsafe_unretained, retain) id p4_1; // expected-error {{property attributes 'unsafe_unretained' and 'retain' are mutually exclusive}} |
| 23 | @property(unsafe_unretained, strong) id s4_1; // expected-error {{property attributes 'unsafe_unretained' and 'strong' are mutually exclusive}} |
| 24 | @property(unsafe_unretained, copy, retain) id p4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'retain' are mutually exclusive}} |
| 25 | @property(unsafe_unretained, copy, strong) id s4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'strong' are mutually exclusive}} |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 26 | |
Ted Kremenek | 08c88db | 2012-05-01 05:56:02 +0000 | [diff] [blame] | 27 | @property id p4; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} |
Steve Naroff | 2bd0372 | 2008-10-21 18:21:45 +0000 | [diff] [blame] | 28 | |
| 29 | @property(nonatomic,copy) int (^includeMailboxCondition)(); |
| 30 | @property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}} |
| 31 | |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 32 | @end |
Fariborz Jahanian | ae415dc | 2010-07-13 22:04:56 +0000 | [diff] [blame] | 33 | |
| 34 | @interface I0() |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 35 | @property (retain) int PROP; // expected-error {{property with 'retain (or strong)' attribute must be of object type}} |
| 36 | @property (strong) int SPROP; // expected-error {{property with 'retain (or strong)' attribute must be of object type}} |
Fariborz Jahanian | ae415dc | 2010-07-13 22:04:56 +0000 | [diff] [blame] | 37 | @property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 38 | @property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}} |
Fariborz Jahanian | ae415dc | 2010-07-13 22:04:56 +0000 | [diff] [blame] | 39 | @end |
Fariborz Jahanian | 48a98c7 | 2011-11-01 23:02:16 +0000 | [diff] [blame] | 40 | |
| 41 | // rdar://10357768 |
| 42 | @interface rdar10357768 |
| 43 | { |
| 44 | int n1; |
| 45 | } |
| 46 | @property (readonly, setter=crushN1:) int n1; // expected-warning {{setter cannot be specified for a readonly property}} |
| 47 | @end |
| 48 | |