[Heikki Kultala] This patch contains the ABI changes for the TCE target.
[clang.git] / test / SemaObjC / property-user-setter.m
blob2f1e19727a88863c3a0645eba29b9e8420fa593a
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 @interface I0 
4 @property(readonly) int x;
5 @property(readonly) int y;
6 @property(readonly) int z;
7 -(void) setY: (int) y0;
8 @end
10 @interface I0 (Cat0)
11 -(void) setX: (int) a0;
12 @end
14 @implementation I0
15 @dynamic x;
16 @dynamic y;
17 @dynamic z;
18 -(void) setY: (int) y0{}
20 -(void) im0 {
21   self.x = 0;
22   self.y = 2;
23   self.z = 2; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
25 @end
27 // Test when property is 'readonly' but it has a setter in
28 // its implementation only.
29 @interface I1  {
31 @property(readonly) int identifier;
32 @end
35 @implementation I1
36 @dynamic identifier;
37 - (void)setIdentifier:(int)ident {}
39 - (id)initWithIdentifier:(int)Arg {
40     self.identifier = 0;
43 @end
46 // Also in a category implementation
47 @interface I1(CAT)  
48 @property(readonly) int rprop;
49 @end
52 @implementation I1(CAT)
53 @dynamic rprop;
54 - (void)setRprop:(int)ident {}
56 - (id)initWithIdentifier:(int)Arg {
57     self.rprop = 0;
60 @end
62 static int g_val;
64 @interface Root 
65 + alloc;
66 - init;
67 @end
69 @interface Subclass : Root
71     int setterOnly;
73 - (void) setSetterOnly:(int)value;
74 @end
76 @implementation Subclass
77 - (void) setSetterOnly:(int)value {
78     setterOnly = value;
79     g_val = setterOnly;
81 @end
83 @interface C {}
84 // - (int)Foo;
85 - (void)setFoo:(int)value;
86 @end
88 void g(int);
90 void f(C *c) {
91     c.Foo = 17; // OK 
92     g(c.Foo); // expected-error {{expected getter method not found on object of type 'C *'}}
96 void abort(void);
97 int main (void) {
98     Subclass *x = [[Subclass alloc] init];
100     x.setterOnly = 4;   // OK
101     if (g_val != 4)
102       abort ();
103     return 0;