xref: /aosp_15_r20/external/clang/test/SemaObjC/property-10.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s  -fblocks
2*67e74705SXin Li
3*67e74705SXin Li// Check property attribute consistency.
4*67e74705SXin Li
5*67e74705SXin Li@interface I0
6*67e74705SXin Li@property(readonly, readwrite) int p0; // expected-error {{property attributes 'readonly' and 'readwrite' are mutually exclusive}}
7*67e74705SXin Li
8*67e74705SXin Li@property(retain) int p1; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
9*67e74705SXin Li@property(strong) int s1; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
10*67e74705SXin Li
11*67e74705SXin Li@property(copy) int p2; // expected-error {{property with 'copy' attribute must be of object type}}
12*67e74705SXin Li
13*67e74705SXin Li@property(assign, copy) id p3_0; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}
14*67e74705SXin Li@property(assign, retain) id p3_1; // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
15*67e74705SXin Li@property(assign, strong) id s3_1; // expected-error {{property attributes 'assign' and 'strong' are mutually exclusive}}
16*67e74705SXin Li@property(copy, retain) id p3_2; // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
17*67e74705SXin Li@property(copy, strong) id s3_2; // expected-error {{property attributes 'copy' and 'strong' are mutually exclusive}}
18*67e74705SXin Li@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}}
19*67e74705SXin Li@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*67e74705SXin Li
21*67e74705SXin Li@property(unsafe_unretained, copy) id p4_0; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}
22*67e74705SXin Li@property(unsafe_unretained, retain) id p4_1; // expected-error {{property attributes 'unsafe_unretained' and 'retain' are mutually exclusive}}
23*67e74705SXin Li@property(unsafe_unretained, strong) id s4_1; // expected-error {{property attributes 'unsafe_unretained' and 'strong' are mutually exclusive}}
24*67e74705SXin Li@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*67e74705SXin Li@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}}
26*67e74705SXin Li
27*67e74705SXin Li@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}}
28*67e74705SXin Li
29*67e74705SXin Li@property(nonatomic,copy) int (^includeMailboxCondition)();
30*67e74705SXin Li@property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}}
31*67e74705SXin Li
32*67e74705SXin Li@end
33*67e74705SXin Li
34*67e74705SXin Li@interface I0()
35*67e74705SXin Li@property (retain) int PROP;	// expected-error {{property with 'retain (or strong)' attribute must be of object type}}
36*67e74705SXin Li@property (strong) int SPROP;	// expected-error {{property with 'retain (or strong)' attribute must be of object type}}
37*67e74705SXin Li@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}}
38*67e74705SXin Li@property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}}
39*67e74705SXin Li@end
40*67e74705SXin Li
41*67e74705SXin Li// rdar://10357768
42*67e74705SXin Li@interface rdar10357768
43*67e74705SXin Li{
44*67e74705SXin Li    int n1;
45*67e74705SXin Li}
46*67e74705SXin Li@property (readonly, setter=crushN1:) int n1; // expected-warning {{setter cannot be specified for a readonly property}}
47*67e74705SXin Li@end
48*67e74705SXin Li
49