Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc.dg / property / at-property-7.m
blob6f5cedaac08a5875f09cc00016dfe889365552ec
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 a non-standard name for the getter.  */
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 (getter = getA, 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) getA
30   return a;
32 - (void) setA: (int)value
34   a = value;
36 @end
38 int main (void)
40   MyRootClass *object = [[MyRootClass alloc] init];
42   object.a = 14;
44   if (object.a != 14)
45     abort ();
47   object.a = 23;
49   if (object.a != 23)
50     abort ();
52   object.a = 78;
54   if (object.a != 78)
55     abort ();
57   return 0;