Debian Codegraph @

gcc/testsuite/obj-c++.dg/property/at-property-10.mm

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 in a number of expressions. */
6
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/runtime.h>
10
11 @interface MyRootClass
12 {
13 Class isa;
14 int a;
15 }
16 @property (nonatomic) int a;
17 + (id) initialize;
18 + (id) alloc;
19 - (id) init;
20 @end
21
22 @implementation MyRootClass
23 + (id) initialize { return self; }
24 + (id) alloc { return class_createInstance (self, 0); }
25 - (id) init { return self; }
26 @synthesize a;
27 @end
28
29 int
30 test (int g)
31 {
32 return g;
33 }
34
35 int main (void)
36 {
37 MyRootClass *object = [[MyRootClass alloc] init];
38 MyRootClass *object2 = [[MyRootClass alloc] init];
39
40 object.a = 14;
41 object.a = object.a + object.a;
42
43 if (object.a != 28)
44 abort ();
45
46 object.a = 99;
47 object.a++;
48
49 if (object.a != 100)
50 abort ();
51
52 object.a = 99;
53 object.a *= 2;
54
55 if (object.a != 198)
56 abort ();
57
58 {
59 int f = object.a;
60
61 if (f != 198)
62 abort ();
63
64 if (f != object.a)
65 abort ();
66
67 if (object.a != f)
68 abort ();
69
70 object.a = object.a;
71
72 if (object.a != 198)
73 abort ();
74 }
75
76 if (test (object.a) != 198)
77 abort ();
78
79 object.a = -object.a;
80
81 if (object.a != -198)
82 abort ();
83
84 for (object.a = 0; object.a < 99; object.a++)
85 object2.a = object.a;
86
87 if (object2.a != object.a - 1)
88 abort ();
89
90 if (object2.a != 98)
91 abort ();
92
93 if (object.a != 99)
94 abort ();
95
96 return (0);
97 }