brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 6b0447f Raw
155 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s2 3@interface I0 4@property(readonly) int x;5@property(readonly) int y;6@property(readonly) int z;7-(void) setY: (int) y0;8@end9 10@interface I0 (Cat0)11-(void) setX: (int) a0;12@end13 14@implementation I015@dynamic x;16@dynamic y;17@dynamic z;18-(void) setY: (int) y0{}19 20-(void) im0 {21  self.x = 0;22  self.y = 2;23  self.z = 2; // expected-error {{assignment to readonly property}}24}25@end26 27// Test when property is 'readonly' but it has a setter in28// its implementation only.29@interface I1  {30}31@property(readonly) int identifier;32@end33 34 35@implementation I136@dynamic identifier;37- (void)setIdentifier:(int)ident {}38 39- (id)initWithIdentifier:(int)Arg {40    self.identifier = 0;41}42 43@end44 45 46// Also in a category implementation47@interface I1(CAT)  48@property(readonly) int rprop;49@end50 51 52@implementation I1(CAT)53@dynamic rprop;54- (void)setRprop:(int)ident {}55 56- (id)initWithIdentifier:(int)Arg {57    self.rprop = 0;58}59 60@end61 62static int g_val;63 64@interface Root 65+ alloc;66- init;67@end68 69@interface Subclass : Root70{71    int setterOnly;72}73- (void) setSetterOnly:(int)value;74@end75 76@implementation Subclass77- (void) setSetterOnly:(int)value {78    setterOnly = value;79    g_val = setterOnly;80}81@end82 83@interface C {}84// - (int)Foo;85- (void)setFoo:(int)value;86@end87 88void g(int);89 90void f(C *c) {91    c.Foo = 17; // OK 92    g(c.Foo); // expected-error {{no getter method for read from property}}93}94 95 96void abort(void);97int main (void) {98    Subclass *x = [[Subclass alloc] init];99 100    x.setterOnly = 4;   // OK101    if (g_val != 4)102      abort ();103    return 0;104}105 106@interface rdar11363363107{108  id R;109}110@property (copy) id p;111@property (copy) id r;112@property (copy) id Q;113@property (copy) id t; // expected-note 2 {{property declared here}}114@property (copy) id T; // expected-note 2 {{property declared here}}115@property (copy) id Pxyz; // expected-note 2 {{property declared here}}116@property (copy) id pxyz; // expected-note 2 {{property declared here}}117@end118 119@implementation rdar11363363120@synthesize p;121@synthesize r;122@synthesize Q;123@synthesize t, T;124@synthesize Pxyz, pxyz;125- (id) Meth {126  self.P = 0; // expected-warning {{property 'P' not found on object of type 'rdar11363363 *'; did you mean to access property p?}}127  self.q = 0; // expected-warning {{property 'q' not found on object of type 'rdar11363363 *'; did you mean to access property Q?}}128  self.t = 0; // expected-error {{synthesized properties 't' and 'T' both claim setter 'setT:'}}129  self.T = 0; // expected-error {{synthesized properties 'T' and 't' both claim setter 'setT:'}}130  self.Pxyz = 0; // expected-error {{synthesized properties 'Pxyz' and 'pxyz' both claim setter 'setPxyz:'}}131  self.pxyz = 0; // expected-error {{synthesized properties 'pxyz' and 'Pxyz' both claim setter 'setPxyz:'}}132  self.r = 0;133  return self.R; // expected-error {{no getter method for read from property}} \134                 // expected-warning {{property 'R' not found on object of type 'rdar11363363 *'; did you mean to access property r?}}135}136@end137 138@class BridgeFormatter;139 140@interface FMXBridgeFormatter 141 142@property(assign, readwrite, getter=formatter, setter=setFormatter:) BridgeFormatter* cppFormatter;143 144@end145 146@implementation FMXBridgeFormatter147@synthesize cppFormatter;148 149- (void) dealloc150{151 self.formatter = 0;152}153@end154 155