Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc.dg / property / at-property-9.m
blob0f144fad261b0c7f56289807dfaa76c636eef846
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 /* Use the simplest synthesized accessor (assign, nonatomic) as we are
18    not testing the synthesized accessors in this test, just the
19    property syntax.  */
20 @property (getter = giveMeA, setter = writeA:, nonatomic) int a;
21 + (id) initialize;
22 + (id) alloc;
23 - (id) init;
24 @end
26 @implementation MyRootClass
27 + (id) initialize { return self; }
28 + (id) alloc { return class_createInstance (self, 0); }
29 - (id) init { return self; }
30 @synthesize a;
31 @end
33 int main (void)
35   MyRootClass *object = [[MyRootClass alloc] init];
37   object.a = 14;
39   if (object.a != 14)
40     abort ();
42   object.a = 23;
44   if (object.a != 23)
45     abort ();
47   object.a = 78;
49   if (object.a != 78)
50     abort ();
52   return 0;