Small ChangeLog tweak.
[official-gcc.git] / gcc / testsuite / objc.dg / property / dotsyntax-5.m
blob06e11303219a67ac6f0fbc6657b8f18ff542e280
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 the 'dot syntax' with self, both in instance and class methods.  */
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 - (int) testMe
49   self.count = 400;
50   if (self.count != 400)
51     abort ();
53   return self.count;
55 + (int) testMe
57   self.classCount = 4000;
58   if (self.classCount != 4000)
59     abort ();
61   return self.classCount;
63 @end
65 int main (void)
67   MyRootClass *object = [[MyRootClass alloc] init];
69   if ([object testMe] != 400)
70     abort ();
72   if ([MyRootClass testMe] != 4000)
73     abort ();
75   return 0;