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 nested 'dot syntax' (xxx.yyy.zzz or [xxx yyy].zzz). */
9 #include <objc/runtime.h>
14 static MyRootClass *shared_root = nil;
16 @interface MyRootClass
24 @property (assign) MyRootClass *next;
26 + (MyRootClass *)sharedInstance;
29 - (MyRootClass *)same;
31 - (void) setCount: (int)count;
34 @implementation MyRootClass
37 + (id) initialize { return self; }
38 + (id) alloc { return class_createInstance (self, 0); }
39 - (id) init { return self; }
40 + (MyRootClass *)sharedInstance
43 shared_root = [[self alloc] init];
55 - (void) setCount: (int)count
63 MyRootClass *object = [[MyRootClass alloc] init];
65 /* Test ClassName.accessor.accessor. */
66 MyRootClass.sharedInstance.count = 500;
67 if (MyRootClass.sharedInstance.count != 500)
70 /* Test object.accessor.accessor. */
71 object.same.count = 1000;
72 if (object.same.count != 1000)
75 /* Test object.accessor.property. */
76 object.same.next = object;
77 if (object.same.next != object)
80 /* Test lots of nesting. */
81 if (object.next.next.same.same.next.next.same != object)
84 /* Test more nesting. */
85 MyRootClass.sharedInstance.next = object;
86 MyRootClass.sharedInstance.next.next.next.next.next.count = 2000;
87 if (MyRootClass.sharedInstance.next.next.next.next.next.count != 2000)
90 /* Test more nesting. */
91 MyRootClass.sharedInstance.same.same.same.same.same.count = 3000;
92 if (MyRootClass.sharedInstance.same.same.same.same.same.count != 3000)
95 /* Test [object method].property. */
96 [MyRootClass sharedInstance].count = 5000;
97 if ([MyRootClass sharedInstance].count != 5000)
100 /* Just a final check. */
101 if (shared_root.count != 5000)