Small ChangeLog tweak.
[official-gcc.git] / gcc / testsuite / objc.dg / property / dotsyntax-12.m
blob20882f909ae1bacd55fd10b1981a2bbb13df7284
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 looking up a setter or getter which are in a protocol attached
6    to a category of a superclass.  */
8 #include <stdlib.h>
9 #include <objc/objc.h>
10 #include <objc/runtime.h>
12 static int c;
14 @interface MyRootClass
16   Class isa;
17   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 @end
30 @protocol count
31 - (int) count;
32 - (void) setCount: (int)count;
33 @end
35 @protocol classCount
36 + (int) classCount;
37 + (void) setClassCount: (int)count;
38 @end
40 @interface MyRootClass (Category) <count, classCount>
41 @end
43 @implementation MyRootClass (Category)
44 - (int) count
46   return a;
48 - (void) setCount: (int)count
50   a = count;
52 + (int) classCount
54   return c;
56 + (void) setClassCount: (int)count
58   c = count;
60 @end
62 @interface MySubClass : MyRootClass
63 + (int) testMe;
64 - (int) testMe;
65 @end
67 @implementation MySubClass
68 - (int) testMe
70   self.count = 400;
71   if (self.count != 400)
72     abort ();             
74   return self.count;
76 + (int) testMe
78   self.classCount = 4000;
79   if (self.classCount != 4000)
80     abort ();
82   return self.classCount;
84 @end
86 int main (void)
88   MySubClass *object = [[MySubClass alloc] init];
90   object.count = 44;
91   if (object.count != 44)
92     abort ();
94   MySubClass.classCount = 40;
95   if (MySubClass.classCount != 40)
96     abort ();
98   if ([object testMe] != 400)
99     abort ();
101   if ([MySubClass testMe] != 4000)
102     abort ();
104   return 0;