]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/objc.dg/property/at-property-22.m
In gcc/objc/: 2010-11-14 Nicola Pero <nicola.pero@meta-innovation.com>
[gcc.git] / gcc / testsuite / objc.dg / property / at-property-22.m
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
5 /* Test properties of different types. */
6
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/runtime.h>
10
11 enum colour { Red, Black };
12
13 @interface MyRootClass
14 {
15 Class isa;
16 }
17 + (id) initialize;
18 + (id) alloc;
19 - (id) init;
20 + (Class) class;
21 @end
22
23 @implementation MyRootClass
24 + (id) initialize { return self; }
25 + (id) alloc { return class_createInstance (self, 0); }
26 - (id) init { return self; }
27 + (Class) class { return self; }
28 @end
29
30
31 @interface MyClass : MyRootClass
32 {
33 /* A bunch of C types. */
34 char pchar;
35 short pshort;
36 int pint;
37 long plong;
38 float pfloat;
39 double pdouble;
40 enum colour penum;
41
42 /* A bunch of pointers to C types. */
43 char *pcharp;
44 short *pshortp;
45 int *pintp;
46 long *plongp;
47 float *pfloatp;
48 double *pdoublep;
49 enum colour *penump;
50
51 /* A bunch of Objective-C types. */
52 id pid;
53 Class pclass;
54 MyClass *pMyClassp;
55 }
56 @property (assign) char pchar;
57 @property (assign) short pshort;
58 @property (assign) int pint;
59 @property (assign) long plong;
60 @property (assign) float pfloat;
61 @property (assign) double pdouble;
62 @property (assign) enum colour penum;
63
64 @property (assign) char *pcharp;
65 @property (assign) short *pshortp;
66 @property (assign) int *pintp;
67 @property (assign) long *plongp;
68 @property (assign) float *pfloatp;
69 @property (assign) double *pdoublep;
70 @property (assign) enum colour *penump;
71
72 @property (assign) id pid;
73 @property (assign) Class pclass;
74 @property (assign) MyClass *pMyClassp;
75 @end
76
77 @implementation MyClass
78 @synthesize pchar;
79 @synthesize pshort;
80 @synthesize pint;
81 @synthesize plong;
82 @synthesize pfloat;
83 @synthesize pdouble;
84 @synthesize penum;
85
86 @synthesize pcharp;
87 @synthesize pshortp;
88 @synthesize pintp;
89 @synthesize plongp;
90 @synthesize pfloatp;
91 @synthesize pdoublep;
92 @synthesize penump;
93
94 @synthesize pid;
95 @synthesize pclass;
96 @synthesize pMyClassp;
97 @end
98
99 int main (void)
100 {
101 MyClass *object = [[MyClass alloc] init];
102
103 object.pchar = 1;
104 if (object.pchar != 1)
105 abort ();
106
107 object.pshort = 2;
108 if (object.pshort != 2)
109 abort ();
110
111 object.pint = 3;
112 if (object.pint != 3)
113 abort ();
114
115 object.plong = 4;
116 if (object.plong != 4)
117 abort ();
118
119 object.pfloat = 0;
120 if (object.pfloat != 0)
121 abort ();
122
123 object.pdouble = 0;
124 if (object.pdouble != 0)
125 abort ();
126
127 object.penum = Black;
128 if (object.penum != Black)
129 abort ();
130
131 object.pcharp = 0;
132 if (object.pcharp != 0)
133 abort ();
134
135 object.pshortp = 0;
136 if (object.pshortp != 0)
137 abort ();
138
139 object.pintp = 0;
140 if (object.pintp != 0)
141 abort ();
142
143 object.plongp = 0;
144 if (object.plongp != 0)
145 abort ();
146
147 object.pfloatp = 0;
148 if (object.pfloatp != 0)
149 abort ();
150
151 object.pdoublep = 0;
152 if (object.pdoublep != 0)
153 abort ();
154
155 object.penump = 0;
156 if (object.penump != 0)
157 abort ();
158
159 object.pid = object;
160 if (object.pid != object)
161 abort ();
162
163 object.pclass = [MyClass class];
164 if (object.pclass != [MyClass class])
165 abort ();
166
167 object.pMyClassp = object;
168 if (object.pMyClassp != object)
169 abort ();
170
171 return 0;
172 }
This page took 0.049111 seconds and 5 git commands to generate.