Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / obj-c++.dg / property / at-property-9.mm
blob4b2b64d3f04239d141324636e1af1a9b561bcf31
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 synthesized setter/getter
6    and with a non-standard name for the getter and setter.  */
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 = giveMeA, setter = writeA:, 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; }
27 @synthesize a;
28 @end
30 int main (void)
32   MyRootClass *object = [[MyRootClass alloc] init];
34   object.a = 14;
36   if (object.a != 14)
37     abort ();
39   object.a = 23;
41   if (object.a != 23)
42     abort ();
44   object.a = 78;
46   if (object.a != 78)
47     abort ();
49   return (0);