blob: 926f964202508ba05b7e39e533551ce04eb45b3e [file] [log] [blame]
Fariborz Jahanian6669db92008-11-25 17:56:43 +00001// RUN: clang -fsyntax-only -verify %s
2
3@interface Object
4- (id)new;
5@end
6
7@interface ReadOnly : Object
8{
9 int _object;
10 int _Anotherobject;
11}
12@property(readonly) int object;
13@property(readonly) int Anotherobject;
14@end
15
16@interface ReadOnly ()
17@property(readwrite) int object;
18@property(readwrite, setter = myAnotherobjectSetter:) int Anotherobject;
19@end
20
21@implementation ReadOnly
22@synthesize object = _object;
23@synthesize Anotherobject = _Anotherobject;
24- (void) myAnotherobjectSetter : (int)val {
25 _Anotherobject = val;
26}
27@end
28
29int main(int argc, char **argv) {
30 ReadOnly *test = [ReadOnly new];
31 test.object = 12345;
32 test.Anotherobject = 200;
33 return test.object - 12345 + test.Anotherobject - 200;
34}
35
Daniel Dunbar84efc042009-01-09 01:04:21 +000036///
37
38@interface I0
39@property(readonly) int p0;
40@end
41
42@interface I0 (Cat0)
43@end
44
45@interface I0 (Cat1)
46@end
47
48@implementation I0
49- (void) foo {
50 self.p0 = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
51}
52@end