1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2*67e74705SXin Li 3*67e74705SXin Li@interface I0 4*67e74705SXin Li@property(readonly) int x; 5*67e74705SXin Li@property(readonly) int y; 6*67e74705SXin Li@property(readonly) int z; 7*67e74705SXin Li-(void) setY: (int) y0; 8*67e74705SXin Li@end 9*67e74705SXin Li 10*67e74705SXin Li@interface I0 (Cat0) 11*67e74705SXin Li-(void) setX: (int) a0; 12*67e74705SXin Li@end 13*67e74705SXin Li 14*67e74705SXin Li@implementation I0 15*67e74705SXin Li@dynamic x; 16*67e74705SXin Li@dynamic y; 17*67e74705SXin Li@dynamic z; 18*67e74705SXin Li-(void) setY: (int) y0{} 19*67e74705SXin Li 20*67e74705SXin Li-(void) im0 { 21*67e74705SXin Li self.x = 0; 22*67e74705SXin Li self.y = 2; 23*67e74705SXin Li self.z = 2; // expected-error {{assignment to readonly property}} 24*67e74705SXin Li} 25*67e74705SXin Li@end 26*67e74705SXin Li 27*67e74705SXin Li// Test when property is 'readonly' but it has a setter in 28*67e74705SXin Li// its implementation only. 29*67e74705SXin Li@interface I1 { 30*67e74705SXin Li} 31*67e74705SXin Li@property(readonly) int identifier; 32*67e74705SXin Li@end 33*67e74705SXin Li 34*67e74705SXin Li 35*67e74705SXin Li@implementation I1 36*67e74705SXin Li@dynamic identifier; 37*67e74705SXin Li- (void)setIdentifier:(int)ident {} 38*67e74705SXin Li 39*67e74705SXin Li- (id)initWithIdentifier:(int)Arg { 40*67e74705SXin Li self.identifier = 0; 41*67e74705SXin Li} 42*67e74705SXin Li 43*67e74705SXin Li@end 44*67e74705SXin Li 45*67e74705SXin Li 46*67e74705SXin Li// Also in a category implementation 47*67e74705SXin Li@interface I1(CAT) 48*67e74705SXin Li@property(readonly) int rprop; 49*67e74705SXin Li@end 50*67e74705SXin Li 51*67e74705SXin Li 52*67e74705SXin Li@implementation I1(CAT) 53*67e74705SXin Li@dynamic rprop; 54*67e74705SXin Li- (void)setRprop:(int)ident {} 55*67e74705SXin Li 56*67e74705SXin Li- (id)initWithIdentifier:(int)Arg { 57*67e74705SXin Li self.rprop = 0; 58*67e74705SXin Li} 59*67e74705SXin Li 60*67e74705SXin Li@end 61*67e74705SXin Li 62*67e74705SXin Listatic int g_val; 63*67e74705SXin Li 64*67e74705SXin Li@interface Root 65*67e74705SXin Li+ alloc; 66*67e74705SXin Li- init; 67*67e74705SXin Li@end 68*67e74705SXin Li 69*67e74705SXin Li@interface Subclass : Root 70*67e74705SXin Li{ 71*67e74705SXin Li int setterOnly; 72*67e74705SXin Li} 73*67e74705SXin Li- (void) setSetterOnly:(int)value; 74*67e74705SXin Li@end 75*67e74705SXin Li 76*67e74705SXin Li@implementation Subclass 77*67e74705SXin Li- (void) setSetterOnly:(int)value { 78*67e74705SXin Li setterOnly = value; 79*67e74705SXin Li g_val = setterOnly; 80*67e74705SXin Li} 81*67e74705SXin Li@end 82*67e74705SXin Li 83*67e74705SXin Li@interface C {} 84*67e74705SXin Li// - (int)Foo; 85*67e74705SXin Li- (void)setFoo:(int)value; 86*67e74705SXin Li@end 87*67e74705SXin Li 88*67e74705SXin Livoid g(int); 89*67e74705SXin Li 90*67e74705SXin Livoid f(C *c) { 91*67e74705SXin Li c.Foo = 17; // OK 92*67e74705SXin Li g(c.Foo); // expected-error {{no getter method for read from property}} 93*67e74705SXin Li} 94*67e74705SXin Li 95*67e74705SXin Li 96*67e74705SXin Livoid abort(void); 97*67e74705SXin Liint main (void) { 98*67e74705SXin Li Subclass *x = [[Subclass alloc] init]; 99*67e74705SXin Li 100*67e74705SXin Li x.setterOnly = 4; // OK 101*67e74705SXin Li if (g_val != 4) 102*67e74705SXin Li abort (); 103*67e74705SXin Li return 0; 104*67e74705SXin Li} 105*67e74705SXin Li 106*67e74705SXin Li// rdar://11363363 107*67e74705SXin Li@interface rdar11363363 108*67e74705SXin Li{ 109*67e74705SXin Li id R; 110*67e74705SXin Li} 111*67e74705SXin Li@property (copy) id p; 112*67e74705SXin Li@property (copy) id r; 113*67e74705SXin Li@property (copy) id Q; 114*67e74705SXin Li@property (copy) id t; // expected-note 2 {{property declared here}} 115*67e74705SXin Li@property (copy) id T; // expected-note 2 {{property declared here}} 116*67e74705SXin Li@property (copy) id Pxyz; // expected-note 2 {{property declared here}} 117*67e74705SXin Li@property (copy) id pxyz; // expected-note 2 {{property declared here}} 118*67e74705SXin Li@end 119*67e74705SXin Li 120*67e74705SXin Li@implementation rdar11363363 121*67e74705SXin Li@synthesize p; 122*67e74705SXin Li@synthesize r; 123*67e74705SXin Li@synthesize Q; 124*67e74705SXin Li@synthesize t, T; 125*67e74705SXin Li@synthesize Pxyz, pxyz; 126*67e74705SXin Li- (id) Meth { 127*67e74705SXin Li self.P = 0; // expected-warning {{property 'P' not found on object of type 'rdar11363363 *'; did you mean to access property p?}} 128*67e74705SXin Li self.q = 0; // expected-warning {{property 'q' not found on object of type 'rdar11363363 *'; did you mean to access property Q?}} 129*67e74705SXin Li// rdar://11528439 130*67e74705SXin Li self.t = 0; // expected-error {{synthesized properties 't' and 'T' both claim setter 'setT:'}} 131*67e74705SXin Li self.T = 0; // expected-error {{synthesized properties 'T' and 't' both claim setter 'setT:'}} 132*67e74705SXin Li self.Pxyz = 0; // expected-error {{synthesized properties 'Pxyz' and 'pxyz' both claim setter 'setPxyz:'}} 133*67e74705SXin Li self.pxyz = 0; // expected-error {{synthesized properties 'pxyz' and 'Pxyz' both claim setter 'setPxyz:'}} 134*67e74705SXin Li self.r = 0; 135*67e74705SXin Li return self.R; // expected-error {{no getter method for read from property}} \ 136*67e74705SXin Li // expected-warning {{property 'R' not found on object of type 'rdar11363363 *'; did you mean to access property r?}} 137*67e74705SXin Li} 138*67e74705SXin Li@end 139*67e74705SXin Li 140*67e74705SXin Li// rdar://11499742 141*67e74705SXin Li@class BridgeFormatter; 142*67e74705SXin Li 143*67e74705SXin Li@interface FMXBridgeFormatter 144*67e74705SXin Li 145*67e74705SXin Li@property(assign, readwrite, getter=formatter, setter=setFormatter:) BridgeFormatter* cppFormatter; 146*67e74705SXin Li 147*67e74705SXin Li@end 148*67e74705SXin Li 149*67e74705SXin Li@implementation FMXBridgeFormatter 150*67e74705SXin Li@synthesize cppFormatter; 151*67e74705SXin Li 152*67e74705SXin Li- (void) dealloc 153*67e74705SXin Li{ 154*67e74705SXin Li self.formatter = 0; 155*67e74705SXin Li} 156*67e74705SXin Li@end 157*67e74705SXin Li 158