In gcc/objc/: 2010-11-08 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / gcc / testsuite / obj-c++.dg / property / at-property-6.mm
blobf2e2044cc3ba313deb6e8e53689a7893511eda3a
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* Test the property syntax with non-synthesized setter/getter
6    and with standard names.  */
8 #include <stdlib.h>
9 #include <objc/objc.h>
10 #include <objc/runtime.h>
12 @interface MyRootClass
14   Class isa;
15   int a;
17 @property (nonatomic) int a;
18 + (id) initialize;
19 + (id) alloc;
20 - (id) init;
21 @end
23 @implementation MyRootClass
24 + (id) initialize { return self; }
25 + (id) alloc { return class_createInstance (self, 0); }
26 - (id) init { return self; }
28 - (int) a
30   return a;
32 - (void) setA: (int)value
34   a = value;
36 @end
38 int main (void)
40   MyRootClass *object = [[MyRootClass alloc] init];
42   if (object.a != 0)
43     abort ();
45   object.a = 14;
47   if (object.a != 14)
48     abort ();
50   object.a = 23;
52   if (object.a != 23)
53     abort ();
55   object.a = 78;
57   if (object.a != 78)
58     abort ();
60   return (0);