Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / obj-c++.dg / property / dotsyntax-1.mm
blob8922f5f03404c87491ffd5ab65836a1a215f43f0
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' without a declarated property.  */
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/runtime.h>
11 @interface MyRootClass
13   Class isa;
14   int a;
15   id b;
17 + (id) initialize;
18 + (id) alloc;
19 - (id) init;
20 - (int) count;
21 - (void) setCount: (int)value;
22 - (id) next;
23 - (void) setNext: (id)value;
24 @end
26 @implementation MyRootClass
27 + (id) initialize { return self; }
28 + (id) alloc { return class_createInstance (self, 0); }
29 - (id) init { return self; }
30 - (int) count
32   return a;
34 - (void) setCount: (int)value
36   a = value;
38 - (id) next
40   return b;
42 - (void) setNext: (id)value
44   b = value;
46 @end
48 int main (void)
50   MyRootClass *object = [[MyRootClass alloc] init];
52   object.count = 40;
53   if (object.count != 40)
54     abort ();
56   object.next = object;
57   if (object.next != object)
58     abort ();
60   return 0;