In gcc/objc/: 2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / gcc / testsuite / objc.dg / property / at-property-11.m
blob2526a9cc1dedf041fee2332b09a43fe828a2cf19
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
2 /* { dg-do run } */
4 /* Test that properties are found even if implemented in superclasses.  */
6 #include <stdlib.h>
7 #include <objc/objc.h>
8 #include <objc/runtime.h>
10 @interface MyRootClass
12   Class isa;
13   int a;
15 /* Use the simplest synthesized accessor (assign, nonatomic) as we are
16    not testing the synthesized accessors in this test, just the
17    property syntax.  */
18 @property (nonatomic) int a;
19 + (id) initialize;
20 + (id) alloc;
21 - (id) init;
22 @end
24 @implementation MyRootClass
25 + (id) initialize { return self; }
26 + (id) alloc { return class_createInstance (self, 0); }
27 - (id) init { return self; }
28 @synthesize a;
29 @end
31 @interface MySubClass : MyRootClass
32 @end
34 @implementation MySubClass
35 @end
37 int main (void)
39   MySubClass *object = [[MySubClass alloc] init];
41   object.a = 40;
42   if (object.a != 40)
43     abort ();
45   return 0;