2013-10-29 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / obj-c++.dg / property / dotsyntax-10.mm
blob433595f3daa1902ea0c6213911d71d82bf586231
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* Test dot-syntax with 'super'.  */
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/runtime.h>
11 static int c;
13 @interface MyRootClass
15   Class isa;
16   int a;
18 + (id) initialize;
19 + (id) alloc;
20 - (id) init;
21 - (int) count;
22 - (void) setCount: (int)count;
23 + (int) classCount;
24 + (void) setClassCount: (int)count;
25 @end
27 @implementation MyRootClass
28 + (id) initialize { return self; }
29 + (id) alloc { return class_createInstance (self, 0); }
30 - (id) init { return self; }
31 - (int) count
33   return a;
35 - (void) setCount: (int)count
37   a = count;
39 + (int) classCount
41   return c;
43 + (void) setClassCount: (int)count
45   c = count;
47 @end
49 @interface MySubClass : MyRootClass
50 + (int) testMe;
51 - (int) testMe;
52 @end
54 @implementation MySubClass
55 - (int) testMe
57   super.count = 400;
58   if (super.count != 400)
59     abort ();
61   return super.count;
63 + (int) testMe
65   super.classCount = 4000;
66   if (super.classCount != 4000)
67     abort ();
69   return super.classCount;
71 @end
73 int main (void)
75   MySubClass *object = [[MySubClass alloc] init];
77   if ([object testMe] != 400)
78     abort ();
80   if ([MySubClass testMe] != 4000)
81     abort ();
83   return 0;