blob: b2aaf2b1a180b5bd289889cc07ccf2350e3e062a [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
Daniel Dunbar95e61fb2008-09-23 21:53:23 +00002
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 McCallf85e1932011-06-15 23:02:42 +00008@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 Dunbar95e61fb2008-09-23 21:53:23 +000010
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 McCallf85e1932011-06-15 23:02:42 +000015@property(assign, strong) id s3_1; // expected-error {{property attributes 'assign' and 'strong' are mutually exclusive}}
Daniel Dunbar95e61fb2008-09-23 21:53:23 +000016@property(copy, retain) id p3_2; // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
John McCallf85e1932011-06-15 23:02:42 +000017@property(copy, strong) id s3_2; // expected-error {{property attributes 'copy' and 'strong' are mutually exclusive}}
Daniel Dunbar95e61fb2008-09-23 21:53:23 +000018@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 McCallf85e1932011-06-15 23:02:42 +000019@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 Dunbar95e61fb2008-09-23 21:53:23 +000026
Ted Kremenek08c88db2012-05-01 05:56:02 +000027@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 Naroff2bd03722008-10-21 18:21:45 +000028
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 Dunbar95e61fb2008-09-23 21:53:23 +000032@end
Fariborz Jahanianae415dc2010-07-13 22:04:56 +000033
34@interface I0()
John McCallf85e1932011-06-15 23:02:42 +000035@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 Jahanianae415dc2010-07-13 22:04:56 +000037@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}}
John McCallf85e1932011-06-15 23:02:42 +000038@property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}}
Fariborz Jahanianae415dc2010-07-13 22:04:56 +000039@end
Fariborz Jahanian48a98c72011-11-01 23:02:16 +000040
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