2012-04-07 02:12:22 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
|
2009-01-11 02:43:55 +08:00
|
|
|
|
|
|
|
@interface I0
|
|
|
|
@property(readonly) int x;
|
|
|
|
@property(readonly) int y;
|
|
|
|
@property(readonly) int z;
|
|
|
|
-(void) setY: (int) y0;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface I0 (Cat0)
|
|
|
|
-(void) setX: (int) a0;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation I0
|
|
|
|
@dynamic x;
|
|
|
|
@dynamic y;
|
|
|
|
@dynamic z;
|
|
|
|
-(void) setY: (int) y0{}
|
|
|
|
|
|
|
|
-(void) im0 {
|
|
|
|
self.x = 0;
|
|
|
|
self.y = 2;
|
2011-10-26 01:37:35 +08:00
|
|
|
self.z = 2; // expected-error {{assignment to readonly property}}
|
2009-01-11 02:43:55 +08:00
|
|
|
}
|
|
|
|
@end
|
2009-01-13 03:55:42 +08:00
|
|
|
|
|
|
|
// Test when property is 'readonly' but it has a setter in
|
|
|
|
// its implementation only.
|
|
|
|
@interface I1 {
|
|
|
|
}
|
|
|
|
@property(readonly) int identifier;
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation I1
|
|
|
|
@dynamic identifier;
|
|
|
|
- (void)setIdentifier:(int)ident {}
|
|
|
|
|
|
|
|
- (id)initWithIdentifier:(int)Arg {
|
|
|
|
self.identifier = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
// Also in a category implementation
|
|
|
|
@interface I1(CAT)
|
|
|
|
@property(readonly) int rprop;
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation I1(CAT)
|
|
|
|
@dynamic rprop;
|
|
|
|
- (void)setRprop:(int)ident {}
|
|
|
|
|
|
|
|
- (id)initWithIdentifier:(int)Arg {
|
|
|
|
self.rprop = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2009-03-11 21:48:17 +08:00
|
|
|
static int g_val;
|
|
|
|
|
|
|
|
@interface Root
|
|
|
|
+ alloc;
|
|
|
|
- init;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Subclass : Root
|
|
|
|
{
|
|
|
|
int setterOnly;
|
|
|
|
}
|
2010-12-23 03:46:35 +08:00
|
|
|
- (void) setSetterOnly:(int)value;
|
2009-03-11 21:48:17 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Subclass
|
|
|
|
- (void) setSetterOnly:(int)value {
|
|
|
|
setterOnly = value;
|
|
|
|
g_val = setterOnly;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2010-01-20 01:48:02 +08:00
|
|
|
@interface C {}
|
|
|
|
// - (int)Foo;
|
2010-12-23 03:46:35 +08:00
|
|
|
- (void)setFoo:(int)value;
|
2010-01-20 01:48:02 +08:00
|
|
|
@end
|
|
|
|
|
2013-04-16 15:28:30 +08:00
|
|
|
void g(int);
|
2010-01-20 01:48:02 +08:00
|
|
|
|
|
|
|
void f(C *c) {
|
2010-12-23 03:46:35 +08:00
|
|
|
c.Foo = 17; // OK
|
2012-11-29 11:13:49 +08:00
|
|
|
g(c.Foo); // expected-error {{no getter method for read from property}}
|
2010-01-20 01:48:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-16 14:28:21 +08:00
|
|
|
void abort(void);
|
2009-03-11 21:48:17 +08:00
|
|
|
int main (void) {
|
|
|
|
Subclass *x = [[Subclass alloc] init];
|
|
|
|
|
2010-12-23 03:46:35 +08:00
|
|
|
x.setterOnly = 4; // OK
|
2009-03-11 21:48:17 +08:00
|
|
|
if (g_val != 4)
|
|
|
|
abort ();
|
|
|
|
return 0;
|
|
|
|
}
|
2012-05-25 02:29:41 +08:00
|
|
|
|
|
|
|
// rdar://11363363
|
|
|
|
@interface rdar11363363
|
|
|
|
{
|
|
|
|
id R;
|
|
|
|
}
|
|
|
|
@property (copy) id p;
|
|
|
|
@property (copy) id r;
|
|
|
|
@property (copy) id Q;
|
2012-05-25 06:48:38 +08:00
|
|
|
@property (copy) id t; // expected-note 2 {{property declared here}}
|
|
|
|
@property (copy) id T; // expected-note 2 {{property declared here}}
|
|
|
|
@property (copy) id Pxyz; // expected-note 2 {{property declared here}}
|
|
|
|
@property (copy) id pxyz; // expected-note 2 {{property declared here}}
|
2012-05-25 02:29:41 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation rdar11363363
|
|
|
|
@synthesize p;
|
|
|
|
@synthesize r;
|
|
|
|
@synthesize Q;
|
|
|
|
@synthesize t, T;
|
2012-05-25 06:48:38 +08:00
|
|
|
@synthesize Pxyz, pxyz;
|
2012-05-25 02:29:41 +08:00
|
|
|
- (id) Meth {
|
2012-05-31 01:33:54 +08:00
|
|
|
self.P = 0;
|
|
|
|
self.q = 0;
|
2012-05-25 06:48:38 +08:00
|
|
|
// rdar://11528439
|
2012-05-27 00:10:06 +08:00
|
|
|
self.t = 0; // expected-error {{synthesized properties 't' and 'T' both claim setter 'setT:'}}
|
|
|
|
self.T = 0; // expected-error {{synthesized properties 'T' and 't' both claim setter 'setT:'}}
|
|
|
|
self.Pxyz = 0; // expected-error {{synthesized properties 'Pxyz' and 'pxyz' both claim setter 'setPxyz:'}}
|
|
|
|
self.pxyz = 0; // expected-error {{synthesized properties 'pxyz' and 'Pxyz' both claim setter 'setPxyz:'}}
|
2012-05-31 01:33:54 +08:00
|
|
|
self.R = 0;
|
2012-11-29 11:13:49 +08:00
|
|
|
return self.R; // expected-error {{no getter method for read from property}}
|
2012-05-31 01:33:54 +08:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
// rdar://11499742
|
|
|
|
@class BridgeFormatter;
|
|
|
|
|
|
|
|
@interface FMXBridgeFormatter
|
|
|
|
|
|
|
|
@property(assign, readwrite, getter=formatter, setter=setFormatter:) BridgeFormatter* cppFormatter;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation FMXBridgeFormatter
|
|
|
|
@synthesize cppFormatter;
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
self.formatter = 0;
|
2012-05-25 02:29:41 +08:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|