Debian Codegraph @

gcc/testsuite/objc.dg/property/at-property-9.m

raw
1 /* Contributed by Nicola Pero <[email protected]>, October 2010. */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
5 /* Test the property syntax with synthesized setter/getter
6 and with a non-standard name for the getter and setter. */
7
8 #include <stdlib.h>
9 #include <objc/objc.h>
10 #include <objc/runtime.h>
11
12 @interface MyRootClass
13 {
14 Class isa;
15 int a;
16 }
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
25
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
32
33 int main (void)
34 {
35 MyRootClass *object = [[MyRootClass alloc] init];
36
37 object.a = 14;
38
39 if (object.a != 14)
40 abort ();
41
42 object.a = 23;
43
44 if (object.a != 23)
45 abort ();
46
47 object.a = 78;
48
49 if (object.a != 78)
50 abort ();
51
52 return 0;
53 }