xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/dot-syntax-1.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -emit-llvm -o %t %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambucint printf(const char *, ...);
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@interface Root
6*f4a2713aSLionel Sambuc-(id) alloc;
7*f4a2713aSLionel Sambuc-(id) init;
8*f4a2713aSLionel Sambuc@end
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc// Property above methods...
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc@interface Top0 : Root
13*f4a2713aSLionel Sambuc@property(getter=_getX,setter=_setX:) int x;
14*f4a2713aSLionel Sambuc@end
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc@interface Bot0 : Top0
17*f4a2713aSLionel Sambuc-(int) x;
18*f4a2713aSLionel Sambuc-(void) setX: (int) arg;
19*f4a2713aSLionel Sambuc@end
20*f4a2713aSLionel Sambuc
21*f4a2713aSLionel Sambuc@implementation Top0
22*f4a2713aSLionel Sambuc-(int) _getX {
23*f4a2713aSLionel Sambuc  printf("-[ Top0 _getX ]\n");
24*f4a2713aSLionel Sambuc  return 0;
25*f4a2713aSLionel Sambuc}
26*f4a2713aSLionel Sambuc-(void) _setX: (int) arg {
27*f4a2713aSLionel Sambuc  printf("-[ Top0 _setX: %d ]\n", arg);
28*f4a2713aSLionel Sambuc}
29*f4a2713aSLionel Sambuc@end
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc@implementation Bot0
32*f4a2713aSLionel Sambuc-(int) x {
33*f4a2713aSLionel Sambuc  printf("-[ Bot0 _getX ]\n");
34*f4a2713aSLionel Sambuc  return 0;
35*f4a2713aSLionel Sambuc}
36*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
37*f4a2713aSLionel Sambuc  printf("-[ Bot0 _setX: %d ]\n", arg);
38*f4a2713aSLionel Sambuc}
39*f4a2713aSLionel Sambuc@end
40*f4a2713aSLionel Sambuc
41*f4a2713aSLionel Sambuc// Methods above property...
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc@interface Top1 : Root
44*f4a2713aSLionel Sambuc-(int) x;
45*f4a2713aSLionel Sambuc-(void) setX: (int) arg;
46*f4a2713aSLionel Sambuc@end
47*f4a2713aSLionel Sambuc
48*f4a2713aSLionel Sambuc@interface Bot1 : Top1
49*f4a2713aSLionel Sambuc@property(getter=_getX,setter=_setX:) int x;
50*f4a2713aSLionel Sambuc@end
51*f4a2713aSLionel Sambuc
52*f4a2713aSLionel Sambuc@implementation Top1
53*f4a2713aSLionel Sambuc-(int) x {
54*f4a2713aSLionel Sambuc  printf("-[ Top1 x ]\n");
55*f4a2713aSLionel Sambuc  return 0;
56*f4a2713aSLionel Sambuc}
57*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
58*f4a2713aSLionel Sambuc  printf("-[ Top1 setX: %d ]\n", arg);
59*f4a2713aSLionel Sambuc}
60*f4a2713aSLionel Sambuc@end
61*f4a2713aSLionel Sambuc
62*f4a2713aSLionel Sambuc@implementation Bot1
63*f4a2713aSLionel Sambuc-(int) _getX {
64*f4a2713aSLionel Sambuc  printf("-[ Bot1 _getX ]\n");
65*f4a2713aSLionel Sambuc  return 0;
66*f4a2713aSLionel Sambuc}
67*f4a2713aSLionel Sambuc-(void) _setX: (int) arg {
68*f4a2713aSLionel Sambuc  printf("-[ Bot1 _setX: %d ]\n", arg);
69*f4a2713aSLionel Sambuc}
70*f4a2713aSLionel Sambuc@end
71*f4a2713aSLionel Sambuc
72*f4a2713aSLionel Sambuc// Mixed setter & getter (variant 1)
73*f4a2713aSLionel Sambuc
74*f4a2713aSLionel Sambuc@interface Top2 : Root
75*f4a2713aSLionel Sambuc-(int) x;
76*f4a2713aSLionel Sambuc-(void) _setX: (int) arg;
77*f4a2713aSLionel Sambuc@end
78*f4a2713aSLionel Sambuc
79*f4a2713aSLionel Sambuc@interface Bot2 : Top2
80*f4a2713aSLionel Sambuc@property(getter=_getX,setter=_setX:) int x;
81*f4a2713aSLionel Sambuc@end
82*f4a2713aSLionel Sambuc
83*f4a2713aSLionel Sambuc@implementation Top2
84*f4a2713aSLionel Sambuc-(int) x {
85*f4a2713aSLionel Sambuc  printf("-[ Top2 x ]\n");
86*f4a2713aSLionel Sambuc  return 0;
87*f4a2713aSLionel Sambuc}
88*f4a2713aSLionel Sambuc-(void) _setX: (int) arg {
89*f4a2713aSLionel Sambuc  printf("-[ Top2 _setX: %d ]\n", arg);
90*f4a2713aSLionel Sambuc}
91*f4a2713aSLionel Sambuc@end
92*f4a2713aSLionel Sambuc
93*f4a2713aSLionel Sambuc@implementation Bot2
94*f4a2713aSLionel Sambuc-(int) _getX {
95*f4a2713aSLionel Sambuc  printf("-[ Bot2 _getX ]\n");
96*f4a2713aSLionel Sambuc  return 0;
97*f4a2713aSLionel Sambuc}
98*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
99*f4a2713aSLionel Sambuc  printf("-[ Bot2 setX: %d ]\n", arg);
100*f4a2713aSLionel Sambuc}
101*f4a2713aSLionel Sambuc@end
102*f4a2713aSLionel Sambuc
103*f4a2713aSLionel Sambuc// Mixed setter & getter (variant 2)
104*f4a2713aSLionel Sambuc
105*f4a2713aSLionel Sambuc@interface Top3 : Root
106*f4a2713aSLionel Sambuc-(int) _getX;
107*f4a2713aSLionel Sambuc-(void) setX: (int) arg;
108*f4a2713aSLionel Sambuc@end
109*f4a2713aSLionel Sambuc
110*f4a2713aSLionel Sambuc@interface Bot3 : Top3
111*f4a2713aSLionel Sambuc@property(getter=_getX,setter=_setX:) int x;
112*f4a2713aSLionel Sambuc@end
113*f4a2713aSLionel Sambuc
114*f4a2713aSLionel Sambuc@implementation Top3
115*f4a2713aSLionel Sambuc-(int) _getX {
116*f4a2713aSLionel Sambuc  printf("-[ Top3 _getX ]\n");
117*f4a2713aSLionel Sambuc  return 0;
118*f4a2713aSLionel Sambuc}
119*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
120*f4a2713aSLionel Sambuc  printf("-[ Top3 setX: %d ]\n", arg);
121*f4a2713aSLionel Sambuc}
122*f4a2713aSLionel Sambuc@end
123*f4a2713aSLionel Sambuc
124*f4a2713aSLionel Sambuc@implementation Bot3
125*f4a2713aSLionel Sambuc-(int) x {
126*f4a2713aSLionel Sambuc  printf("-[ Bot3 x ]\n");
127*f4a2713aSLionel Sambuc  return 0;
128*f4a2713aSLionel Sambuc}
129*f4a2713aSLionel Sambuc-(void) _setX: (int) arg {
130*f4a2713aSLionel Sambuc  printf("-[ Bot3 _setX: %d ]\n", arg);
131*f4a2713aSLionel Sambuc}
132*f4a2713aSLionel Sambuc@end
133*f4a2713aSLionel Sambuc
134*f4a2713aSLionel Sambuc// Mixed setter & getter (variant 3)
135*f4a2713aSLionel Sambuc
136*f4a2713aSLionel Sambuc@interface Top4 : Root
137*f4a2713aSLionel Sambuc@property(getter=_getX,setter=_setX:) int x;
138*f4a2713aSLionel Sambuc@end
139*f4a2713aSLionel Sambuc
140*f4a2713aSLionel Sambuc@interface Bot4 : Top4
141*f4a2713aSLionel Sambuc-(int) _getX;
142*f4a2713aSLionel Sambuc-(void) setX: (int) arg;
143*f4a2713aSLionel Sambuc@end
144*f4a2713aSLionel Sambuc
145*f4a2713aSLionel Sambuc@implementation Top4
146*f4a2713aSLionel Sambuc-(int) x {
147*f4a2713aSLionel Sambuc  printf("-[ Top4 x ]\n");
148*f4a2713aSLionel Sambuc  return 0;
149*f4a2713aSLionel Sambuc}
150*f4a2713aSLionel Sambuc-(void) _setX: (int) arg {
151*f4a2713aSLionel Sambuc  printf("-[ Top4 _setX: %d ]\n", arg);
152*f4a2713aSLionel Sambuc}
153*f4a2713aSLionel Sambuc@end
154*f4a2713aSLionel Sambuc
155*f4a2713aSLionel Sambuc@implementation Bot4
156*f4a2713aSLionel Sambuc-(int) _getX {
157*f4a2713aSLionel Sambuc  printf("-[ Bot4 _getX ]\n");
158*f4a2713aSLionel Sambuc  return 0;
159*f4a2713aSLionel Sambuc}
160*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
161*f4a2713aSLionel Sambuc  printf("-[ Bot4 setX: %d ]\n", arg);
162*f4a2713aSLionel Sambuc}
163*f4a2713aSLionel Sambuc@end
164*f4a2713aSLionel Sambuc
165*f4a2713aSLionel Sambuc// Mixed setter & getter (variant 4)
166*f4a2713aSLionel Sambuc
167*f4a2713aSLionel Sambuc@interface Top5 : Root
168*f4a2713aSLionel Sambuc@property(getter=_getX,setter=_setX:) int x;
169*f4a2713aSLionel Sambuc@end
170*f4a2713aSLionel Sambuc
171*f4a2713aSLionel Sambuc@interface Bot5 : Top5
172*f4a2713aSLionel Sambuc-(int) x;
173*f4a2713aSLionel Sambuc-(void) _setX: (int) arg;
174*f4a2713aSLionel Sambuc@end
175*f4a2713aSLionel Sambuc
176*f4a2713aSLionel Sambuc@implementation Top5
177*f4a2713aSLionel Sambuc-(int) _getX {
178*f4a2713aSLionel Sambuc  printf("-[ Top5 _getX ]\n");
179*f4a2713aSLionel Sambuc  return 0;
180*f4a2713aSLionel Sambuc}
181*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
182*f4a2713aSLionel Sambuc  printf("-[ Top5 setX: %d ]\n", arg);
183*f4a2713aSLionel Sambuc}
184*f4a2713aSLionel Sambuc@end
185*f4a2713aSLionel Sambuc
186*f4a2713aSLionel Sambuc@implementation Bot5
187*f4a2713aSLionel Sambuc-(int) x {
188*f4a2713aSLionel Sambuc  printf("-[ Bot5 x ]\n");
189*f4a2713aSLionel Sambuc  return 0;
190*f4a2713aSLionel Sambuc}
191*f4a2713aSLionel Sambuc-(void) _setX: (int) arg {
192*f4a2713aSLionel Sambuc  printf("-[ Bot5 _setX: %d ]\n", arg);
193*f4a2713aSLionel Sambuc}
194*f4a2713aSLionel Sambuc@end
195*f4a2713aSLionel Sambuc
196*f4a2713aSLionel Sambuc// Mixed level calls (variant 1)
197*f4a2713aSLionel Sambuc
198*f4a2713aSLionel Sambuc@interface Top6 : Root
199*f4a2713aSLionel Sambuc-(int) x;
200*f4a2713aSLionel Sambuc@end
201*f4a2713aSLionel Sambuc
202*f4a2713aSLionel Sambuc@interface Bot6 : Top6
203*f4a2713aSLionel Sambuc-(void) setX: (int) arg;
204*f4a2713aSLionel Sambuc@end
205*f4a2713aSLionel Sambuc
206*f4a2713aSLionel Sambuc@implementation Top6
207*f4a2713aSLionel Sambuc-(int) x {
208*f4a2713aSLionel Sambuc  printf("-[ Top6 x ]\n");
209*f4a2713aSLionel Sambuc  return 0;
210*f4a2713aSLionel Sambuc}
211*f4a2713aSLionel Sambuc@end
212*f4a2713aSLionel Sambuc
213*f4a2713aSLionel Sambuc@implementation Bot6
214*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
215*f4a2713aSLionel Sambuc  printf("-[ Bot5 setX: %d ]\n", arg);
216*f4a2713aSLionel Sambuc}
217*f4a2713aSLionel Sambuc@end
218*f4a2713aSLionel Sambuc
219*f4a2713aSLionel Sambuc// Mixed level calls (variant 1)
220*f4a2713aSLionel Sambuc
221*f4a2713aSLionel Sambuc@interface Top7 : Root
222*f4a2713aSLionel Sambuc-(void) setX: (int) arg;
223*f4a2713aSLionel Sambuc@end
224*f4a2713aSLionel Sambuc
225*f4a2713aSLionel Sambuc@interface Bot7 : Top7
226*f4a2713aSLionel Sambuc-(int) x;
227*f4a2713aSLionel Sambuc@end
228*f4a2713aSLionel Sambuc
229*f4a2713aSLionel Sambuc@implementation Top7
230*f4a2713aSLionel Sambuc-(void) setX: (int) arg {
231*f4a2713aSLionel Sambuc  printf("-[ Top7 setX: %d ]\n", arg);
232*f4a2713aSLionel Sambuc}
233*f4a2713aSLionel Sambuc@end
234*f4a2713aSLionel Sambuc
235*f4a2713aSLionel Sambuc@implementation Bot7
236*f4a2713aSLionel Sambuc-(int) x {
237*f4a2713aSLionel Sambuc  printf("-[ Bot7 x ]\n");
238*f4a2713aSLionel Sambuc  return 0;
239*f4a2713aSLionel Sambuc}
240*f4a2713aSLionel Sambuc@end
241*f4a2713aSLionel Sambuc
242*f4a2713aSLionel Sambuc//
243*f4a2713aSLionel Sambuc
244*f4a2713aSLionel Sambuc// FIXME: Two more (thats it?) interesting cases. Method access on
245*f4a2713aSLionel Sambuc// getter w/o setter and method access on setter w/o getter.
246*f4a2713aSLionel Sambuc
247*f4a2713aSLionel Sambucint main() {
248*f4a2713aSLionel Sambuc#define test(N) { \
249*f4a2713aSLionel Sambuc  Bot##N *ob = [[Bot##N alloc] init]; \
250*f4a2713aSLionel Sambuc  int x = ob.x; \
251*f4a2713aSLionel Sambuc  ob.x = 10; }
252*f4a2713aSLionel Sambuc
253*f4a2713aSLionel Sambuc  test(0);
254*f4a2713aSLionel Sambuc  test(1);
255*f4a2713aSLionel Sambuc  test(2);
256*f4a2713aSLionel Sambuc  test(3);
257*f4a2713aSLionel Sambuc  test(4);
258*f4a2713aSLionel Sambuc  test(5);
259*f4a2713aSLionel Sambuc  //  test(6);
260*f4a2713aSLionel Sambuc  //  test(7);
261*f4a2713aSLionel Sambuc
262*f4a2713aSLionel Sambuc  return 0;
263*f4a2713aSLionel Sambuc}
264*f4a2713aSLionel Sambuc
265