xref: /aosp_15_r20/external/clang/test/SemaObjC/property-impl-misuse.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*67e74705SXin Li
3*67e74705SXin Li@interface I {
4*67e74705SXin Li  int Y;
5*67e74705SXin Li}
6*67e74705SXin Li@property int X;
7*67e74705SXin Li@property int Y;
8*67e74705SXin Li@property int Z;
9*67e74705SXin Li@end
10*67e74705SXin Li
11*67e74705SXin Li@implementation I
12*67e74705SXin Li@dynamic X; // expected-note {{previous declaration is here}}
13*67e74705SXin Li@dynamic X; // expected-error {{property 'X' is already implemented}}
14*67e74705SXin Li@synthesize Y; // expected-note {{previous use is here}}
15*67e74705SXin Li@synthesize Z=Y; // expected-error {{synthesized properties 'Z' and 'Y' both claim instance variable 'Y'}}
16*67e74705SXin Li@end
17*67e74705SXin Li
18*67e74705SXin Li// rdar://8703553
19*67e74705SXin Li@interface IDEPathCell
20*67e74705SXin Li{
21*67e74705SXin Li@private
22*67e74705SXin Li    id _gradientStyle;
23*67e74705SXin Li}
24*67e74705SXin Li
25*67e74705SXin Li@property (readwrite, assign, nonatomic) id gradientStyle;
26*67e74705SXin Li@end
27*67e74705SXin Li
28*67e74705SXin Li@implementation IDEPathCell
29*67e74705SXin Li
30*67e74705SXin Li@synthesize gradientStyle = _gradientStyle;
31*67e74705SXin Li- (void)setGradientStyle:(id)value { }
32*67e74705SXin Li
33*67e74705SXin Li+ (id)_componentCellWithRepresentedObject {
34*67e74705SXin Li    return self.gradientStyle;
35*67e74705SXin Li}
36*67e74705SXin Li@end
37*67e74705SXin Li
38*67e74705SXin Li// rdar://11054153
39*67e74705SXin Li@interface rdar11054153
40*67e74705SXin Li@property int P; // expected-error {{type of property 'P' ('int') does not match type of accessor 'P' ('void')}}
41*67e74705SXin Li- (void)P; // expected-note {{declared here}}
42*67e74705SXin Li
43*67e74705SXin Li@property int P1; // expected-warning {{type of property 'P1' does not match type of accessor 'P1'}}
44*67e74705SXin Li- (double) P1; // expected-note {{declared here}}
45*67e74705SXin Li
46*67e74705SXin Li@property int P2; // expected-error {{type of property 'P2' ('int') does not match type of accessor 'P2' ('double *')}}
47*67e74705SXin Li- (double*)P2; // expected-note {{declared here}}
48*67e74705SXin Li
49*67e74705SXin Li@end
50