Fariborz Jahanian | 2129212 | 2009-01-10 18:43:55 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 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 |
| 9 | |
| 10 | @interface I0 (Cat0) |
| 11 | -(void) setX: (int) a0; |
| 12 | @end |
| 13 | |
| 14 | @implementation I0 |
| 15 | @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 {{assigning to property with 'readonly' attribute not allowed}} |
| 24 | } |
| 25 | @end |
Fariborz Jahanian | d1fa644 | 2009-01-12 19:55:42 +0000 | [diff] [blame] | 26 | |
| 27 | // Test when property is 'readonly' but it has a setter in |
| 28 | // its implementation only. |
| 29 | @interface I1 { |
| 30 | } |
| 31 | @property(readonly) int identifier; |
| 32 | @end |
| 33 | |
| 34 | |
| 35 | @implementation I1 |
| 36 | @dynamic identifier; |
| 37 | - (void)setIdentifier:(int)ident {} |
| 38 | |
| 39 | - (id)initWithIdentifier:(int)Arg { |
| 40 | self.identifier = 0; |
| 41 | } |
| 42 | |
| 43 | @end |
| 44 | |
| 45 | |
| 46 | // Also in a category implementation |
| 47 | @interface I1(CAT) |
| 48 | @property(readonly) int rprop; |
| 49 | @end |
| 50 | |
| 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 | @end |
| 61 | |