Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Fariborz Jahanian | b7611f2 | 2008-11-22 18:40:47 +0000 | [diff] [blame] | 2 | |
| 3 | @interface A |
| 4 | -(int) x; |
| 5 | @property (readonly) int x; |
| 6 | @property int ok; |
| 7 | @end |
| 8 | |
Fariborz Jahanian | ba8d2d6 | 2008-11-22 20:25:50 +0000 | [diff] [blame] | 9 | @interface B |
| 10 | -(void) setOk:(int)arg; |
| 11 | -(int) x; |
| 12 | -(int) ok; |
| 13 | @end |
| 14 | |
| 15 | void f0(A *a, B* b) { |
Fariborz Jahanian | b7611f2 | 2008-11-22 18:40:47 +0000 | [diff] [blame] | 16 | a.x = 10; // expected-error {{assigning to property with 'readonly' attribute not allowed}} |
| 17 | a.ok = 20; |
Fariborz Jahanian | ba8d2d6 | 2008-11-22 20:25:50 +0000 | [diff] [blame] | 18 | b.x = 10; // expected-error {{setter method is needed to assign to object using property assignment syntax}} |
| 19 | b.ok = 20; |
Fariborz Jahanian | b7611f2 | 2008-11-22 18:40:47 +0000 | [diff] [blame] | 20 | } |
| 21 | |
Fariborz Jahanian | c3f48cd | 2009-09-14 16:40:48 +0000 | [diff] [blame] | 22 | typedef struct { |
| 23 | int i1, i2; |
| 24 | } NSRect; |
| 25 | |
| 26 | NSRect NSMakeRect(); |
| 27 | |
| 28 | @interface NSWindow |
| 29 | { |
| 30 | NSRect _frame; |
| 31 | } |
| 32 | - (NSRect)frame; |
| 33 | @end |
| 34 | |
| 35 | @interface NSWindow (Category) |
| 36 | -(void)methodToMakeClangCrash; |
| 37 | @end |
| 38 | |
| 39 | @implementation NSWindow (Category) |
| 40 | -(void)methodToMakeClangCrash |
| 41 | { |
| 42 | self.frame = NSMakeRect(); // expected-error {{setter method is needed to assign to object using property assignment syntax}} |
| 43 | } |
| 44 | @end |