xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/property-error-readonly-assign.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@interface A
4*f4a2713aSLionel Sambuc -(int) x;
5*f4a2713aSLionel Sambuc@property (readonly) int x;
6*f4a2713aSLionel Sambuc@property int ok;
7*f4a2713aSLionel Sambuc@end
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc@interface B
10*f4a2713aSLionel Sambuc -(void) setOk:(int)arg;
11*f4a2713aSLionel Sambuc -(int) x;
12*f4a2713aSLionel Sambuc -(int) ok;
13*f4a2713aSLionel Sambuc@end
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambucvoid f0(A *a, B* b) {
16*f4a2713aSLionel Sambuc  a.x = 10;  // expected-error {{assignment to readonly property}}
17*f4a2713aSLionel Sambuc  a.ok = 20;
18*f4a2713aSLionel Sambuc  b.x = 10;  // expected-error {{no setter method 'setX:' for assignment to property}}
19*f4a2713aSLionel Sambuc  b.ok = 20;
20*f4a2713aSLionel Sambuc}
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuctypedef struct {
23*f4a2713aSLionel Sambuc  int i1, i2;
24*f4a2713aSLionel Sambuc} NSRect;
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel SambucNSRect NSMakeRect();
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel Sambuc@interface NSWindow
29*f4a2713aSLionel Sambuc{
30*f4a2713aSLionel Sambuc    NSRect _frame;
31*f4a2713aSLionel Sambuc}
32*f4a2713aSLionel Sambuc- (NSRect)frame;
33*f4a2713aSLionel Sambuc@end
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc@interface NSWindow (Category)
36*f4a2713aSLionel Sambuc-(void)methodToMakeClangCrash;
37*f4a2713aSLionel Sambuc@end
38*f4a2713aSLionel Sambuc
39*f4a2713aSLionel Sambuc@implementation NSWindow (Category)
40*f4a2713aSLionel Sambuc-(void)methodToMakeClangCrash
41*f4a2713aSLionel Sambuc{
42*f4a2713aSLionel Sambuc self.frame =  NSMakeRect(); // expected-error {{no setter method 'setFrame:' for assignment to property}}
43*f4a2713aSLionel Sambuc}
44*f4a2713aSLionel Sambuc@end
45