1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* Test dot-syntax with super in a category. */
9 #include <objc/runtime.h>
11 @interface MyRootClass
20 - (void) setCount: (int)count;
23 @implementation MyRootClass
24 + (id) initialize { return self; }
25 + (id) alloc { return class_createInstance (self, 0); }
26 - (id) init { return self; }
31 - (void) setCount: (int)count
37 /* First, test 'super' in the main implementation of a subclass. */
38 @interface MySubClass : MyRootClass
40 - (void) setSuperCount: (int)count;
43 @implementation MySubClass
48 - (void) setSuperCount: (int)count
54 /* Now, test 'super' in a category of a subclass. */
55 @interface MySubClass (Category)
57 - (void) setSuperCount2: (int)count;
61 @implementation MySubClass (Category)
66 - (void) setSuperCount2: (int)count
72 /* For positive x, the following will leave super.count
77 super.count = (x < 0 ? x : super.count);
79 if ((x = super.count))
82 if ((x = super.count))
85 /* Finally, also put a bit of self.count in the mix. */
95 MySubClass *object = [[MySubClass alloc] init];
98 if (object.count != 10)
101 object.superCount = 11;
102 if (object.superCount != 11)
105 object.superCount2 = 12;
106 if (object.superCount2 != 12)
109 if ([object test: 45] != 12)