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>
13 static MyRootClass *shared_root = nil;
15 @interface MyRootClass
23 @property (assign) MyRootClass *next;
25 + (MyRootClass *)sharedInstance;
28 - (MyRootClass *)same;
30 - (void) setCount: (int)count;
33 @implementation MyRootClass
36 + (id) initialize { return self; }
37 + (id) alloc { return class_createInstance (self, 0); }
38 - (id) init { return self; }
39 + (MyRootClass *)sharedInstance
42 shared_root = [[self alloc] init];
54 - (void) setCount: (int)count
62 MyRootClass *object = [[MyRootClass alloc] init];
64 /* Test ClassName.accessor.accessor. */
65 MyRootClass.sharedInstance.count = 500;
66 if (MyRootClass.sharedInstance.count != 500)
69 /* Test object.accessor.accessor. */
70 object.same.count = 1000;
71 if (object.same.count != 1000)
74 /* Test object.accessor.property. */
75 object.same.next = object;
76 if (object.same.next != object)
79 /* Test lots of nesting. */
80 if (object.next.next.same.same.next.next.same != object)
83 /* Test more nesting. */
84 MyRootClass.sharedInstance.next = object;
85 MyRootClass.sharedInstance.next.next.next.next.next.count = 2000;
86 if (MyRootClass.sharedInstance.next.next.next.next.next.count != 2000)
89 /* Test more nesting. */
90 MyRootClass.sharedInstance.same.same.same.same.same.count = 3000;
91 if (MyRootClass.sharedInstance.same.same.same.same.same.count != 3000)
94 /* Test [object method].property. */
95 [MyRootClass sharedInstance].count = 5000;
96 if ([MyRootClass sharedInstance].count != 5000)
99 /* Just a final check. */
100 if (shared_root.count != 5000)