xref: /aosp_15_r20/external/clang/test/SemaObjC/tentative-property-decl.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -Weverything -verify %s
2*67e74705SXin Li// expected-no-diagnostics
3*67e74705SXin Li// rdar://11656982
4*67e74705SXin Li/** A property may not be both 'readonly' and having a memory management attribute
5*67e74705SXin Li    (copy/retain/etc.). But, property declaration in primary class and protcols
6*67e74705SXin Li    are tentative as they may be overridden into a 'readwrite' property in class
7*67e74705SXin Li    extensions. So, do not issue any warning on 'readonly' and memory management
8*67e74705SXin Li    attributes in a property.
9*67e74705SXin Li*/
10*67e74705SXin Li
11*67e74705SXin Li@interface Super {
12*67e74705SXin Li}
13*67e74705SXin Li@end
14*67e74705SXin Li
15*67e74705SXin Li@class NSString;
16*67e74705SXin Li
17*67e74705SXin Li@interface MyClass : Super
18*67e74705SXin Li@property(nonatomic, copy, readonly) NSString *prop;
19*67e74705SXin Li@property(nonatomic, copy, readonly) id warnProp;
20*67e74705SXin Li@end
21*67e74705SXin Li
22*67e74705SXin Li@interface MyClass ()
23*67e74705SXin Li@property(nonatomic, copy, readwrite) NSString *prop;
24*67e74705SXin Li@end
25*67e74705SXin Li
26*67e74705SXin Li@implementation MyClass
27*67e74705SXin Li@synthesize prop;
28*67e74705SXin Li@synthesize warnProp;
29*67e74705SXin Li@end
30*67e74705SXin Li
31*67e74705SXin Li
32*67e74705SXin Li@protocol P
33*67e74705SXin Li@property(nonatomic, copy, readonly) NSString *prop;
34*67e74705SXin Li@property(nonatomic, copy, readonly) id warnProp;
35*67e74705SXin Li@end
36*67e74705SXin Li
37*67e74705SXin Li@interface YourClass : Super <P>
38*67e74705SXin Li@end
39*67e74705SXin Li
40*67e74705SXin Li@interface YourClass ()
41*67e74705SXin Li@property(nonatomic, copy, readwrite) NSString *prop;
42*67e74705SXin Li@end
43*67e74705SXin Li
44*67e74705SXin Li@implementation YourClass
45*67e74705SXin Li@synthesize prop;
46*67e74705SXin Li@synthesize warnProp;
47*67e74705SXin Li@end
48*67e74705SXin Li
49