Debian Codegraph @

gcc/testsuite/objc.dg/property/synthesize-2.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 #include <objc/objc.h>
6 #include <objc/runtime.h>
7 #include <stdlib.h>
8
9 @interface MyRootClass
10 {
11 Class isa;
12 }
13 + (id) initialize;
14 + (id) alloc;
15 - (id) init;
16 @end
17
18 @implementation MyRootClass
19 + (id) initialize { return self; }
20 + (id) alloc { return class_createInstance (self, 0); }
21 - (id) init { return self; }
22 @end
23
24 @interface Test : MyRootClass
25 {
26 int v1;
27 }
28 @property int v1;
29 /* TODO: Test more types of properties with different semantics
30 (retain, copy, atomic, nonatomic, and test various C and
31 Objective-C types). */
32 @end
33
34 @implementation Test
35 @synthesize v1;
36 @end
37
38 int main (void)
39 {
40 Test *object = [[Test alloc] init];
41
42 /* Check that the synthesized methods exist and work. Do not invoke
43 them via property syntax - that is another test. Here we just
44 want to test the synthesis of the methods. */
45 [object setV1: 400];
46
47 if ([object v1] != 400)
48 abort ();
49
50 return 0;
51 }