gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / structs.c
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 1996, 1999, 2003, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 /* Useful abreviations. */
20 typedef void t;
21 typedef char tc;
22 typedef short ts;
23 typedef int ti;
24 typedef long tl;
25 typedef long long tll;
26 typedef float tf;
27 typedef double td;
28 typedef long double tld;
29
30 /* Force the type of each field. */
31 #ifndef tA
32 typedef t tA;
33 #endif
34 #ifndef tB
35 typedef tA tB;
36 #endif
37 #ifndef tC
38 typedef tB tC;
39 #endif
40 #ifndef tD
41 typedef tC tD;
42 #endif
43 #ifndef tE
44 typedef tD tE;
45 #endif
46 #ifndef tF
47 typedef tE tF;
48 #endif
49 #ifndef tG
50 typedef tF tG;
51 #endif
52 #ifndef tH
53 typedef tG tH;
54 #endif
55 #ifndef tI
56 typedef tH tI;
57 #endif
58 #ifndef tJ
59 typedef tI tJ;
60 #endif
61 #ifndef tK
62 typedef tJ tK;
63 #endif
64 #ifndef tL
65 typedef tK tL;
66 #endif
67 #ifndef tM
68 typedef tL tM;
69 #endif
70 #ifndef tN
71 typedef tM tN;
72 #endif
73 #ifndef tO
74 typedef tN tO;
75 #endif
76 #ifndef tP
77 typedef tO tP;
78 #endif
79 #ifndef tQ
80 typedef tP tQ;
81 #endif
82 #ifndef tR
83 typedef tQ tR;
84 #endif
85
86 struct struct1 {tA a;};
87 struct struct2 {tA a; tB b;};
88 struct struct3 {tA a; tB b; tC c; };
89 struct struct4 {tA a; tB b; tC c; tD d; };
90 struct struct5 {tA a; tB b; tC c; tD d; tE e; };
91 struct struct6 {tA a; tB b; tC c; tD d; tE e; tF f; };
92 struct struct7 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; };
93 struct struct8 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; };
94 struct struct9 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; };
95 struct struct10 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; };
96 struct struct11 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; };
97 struct struct12 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; };
98 struct struct13 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; };
99 struct struct14 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; };
100 struct struct15 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; };
101 struct struct16 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; };
102 struct struct17 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; };
103 struct struct18 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; tR r; };
104
105 struct struct1 foo1 = {'1'}, L1;
106 struct struct2 foo2 = {'a','2'}, L2;
107 struct struct3 foo3 = {'1','b','3'}, L3;
108 struct struct4 foo4 = {'a','2','c','4'}, L4;
109 struct struct5 foo5 = {'1','b','3','d','5'}, L5;
110 struct struct6 foo6 = {'a','2','c','4','e','6'}, L6;
111 struct struct7 foo7 = {'1','b','3','d','5','f','7'}, L7;
112 struct struct8 foo8 = {'a','2','c','4','e','6','g','8'}, L8;
113 struct struct9 foo9 = {'1','b','3','d','5','f','7','h','9'}, L9;
114 struct struct10 foo10 = {'a','2','c','4','e','6','g','8','i','A'}, L10;
115 struct struct11 foo11 = {'1','b','3','d','5','f','7','h','9','j','B'}, L11;
116 struct struct12 foo12 = {'a','2','c','4','e','6','g','8','i','A','k','C'}, L12;
117 struct struct13 foo13 = {'1','b','3','d','5','f','7','h','9','j','B','l','D'}, L13;
118 struct struct14 foo14 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E'}, L14;
119 struct struct15 foo15 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F'}, L15;
120 struct struct16 foo16 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G'}, L16;
121 struct struct17 foo17 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F','p','H'}, L17;
122 struct struct18 foo18 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G','q','I'}, L18;
123
124 struct struct1 fun1()
125 {
126 return foo1;
127 }
128 struct struct2 fun2()
129 {
130 return foo2;
131 }
132 struct struct3 fun3()
133 {
134 return foo3;
135 }
136 struct struct4 fun4()
137 {
138 return foo4;
139 }
140 struct struct5 fun5()
141 {
142 return foo5;
143 }
144 struct struct6 fun6()
145 {
146 return foo6;
147 }
148 struct struct7 fun7()
149 {
150 return foo7;
151 }
152 struct struct8 fun8()
153 {
154 return foo8;
155 }
156 struct struct9 fun9()
157 {
158 return foo9;
159 }
160 struct struct10 fun10()
161 {
162 return foo10;
163 }
164 struct struct11 fun11()
165 {
166 return foo11;
167 }
168 struct struct12 fun12()
169 {
170 return foo12;
171 }
172 struct struct13 fun13()
173 {
174 return foo13;
175 }
176 struct struct14 fun14()
177 {
178 return foo14;
179 }
180 struct struct15 fun15()
181 {
182 return foo15;
183 }
184 struct struct16 fun16()
185 {
186 return foo16;
187 }
188 struct struct17 fun17()
189 {
190 return foo17;
191 }
192 struct struct18 fun18()
193 {
194 return foo18;
195 }
196
197 #ifdef PROTOTYPES
198 void Fun1(struct struct1 foo1)
199 #else
200 void Fun1(foo1)
201 struct struct1 foo1;
202 #endif
203 {
204 L1 = foo1;
205 }
206 #ifdef PROTOTYPES
207 void Fun2(struct struct2 foo2)
208 #else
209 void Fun2(foo2)
210 struct struct2 foo2;
211 #endif
212 {
213 L2 = foo2;
214 }
215 #ifdef PROTOTYPES
216 void Fun3(struct struct3 foo3)
217 #else
218 void Fun3(foo3)
219 struct struct3 foo3;
220 #endif
221 {
222 L3 = foo3;
223 }
224 #ifdef PROTOTYPES
225 void Fun4(struct struct4 foo4)
226 #else
227 void Fun4(foo4)
228 struct struct4 foo4;
229 #endif
230 {
231 L4 = foo4;
232 }
233 #ifdef PROTOTYPES
234 void Fun5(struct struct5 foo5)
235 #else
236 void Fun5(foo5)
237 struct struct5 foo5;
238 #endif
239 {
240 L5 = foo5;
241 }
242 #ifdef PROTOTYPES
243 void Fun6(struct struct6 foo6)
244 #else
245 void Fun6(foo6)
246 struct struct6 foo6;
247 #endif
248 {
249 L6 = foo6;
250 }
251 #ifdef PROTOTYPES
252 void Fun7(struct struct7 foo7)
253 #else
254 void Fun7(foo7)
255 struct struct7 foo7;
256 #endif
257 {
258 L7 = foo7;
259 }
260 #ifdef PROTOTYPES
261 void Fun8(struct struct8 foo8)
262 #else
263 void Fun8(foo8)
264 struct struct8 foo8;
265 #endif
266 {
267 L8 = foo8;
268 }
269 #ifdef PROTOTYPES
270 void Fun9(struct struct9 foo9)
271 #else
272 void Fun9(foo9)
273 struct struct9 foo9;
274 #endif
275 {
276 L9 = foo9;
277 }
278 #ifdef PROTOTYPES
279 void Fun10(struct struct10 foo10)
280 #else
281 void Fun10(foo10)
282 struct struct10 foo10;
283 #endif
284 {
285 L10 = foo10;
286 }
287 #ifdef PROTOTYPES
288 void Fun11(struct struct11 foo11)
289 #else
290 void Fun11(foo11)
291 struct struct11 foo11;
292 #endif
293 {
294 L11 = foo11;
295 }
296 #ifdef PROTOTYPES
297 void Fun12(struct struct12 foo12)
298 #else
299 void Fun12(foo12)
300 struct struct12 foo12;
301 #endif
302 {
303 L12 = foo12;
304 }
305 #ifdef PROTOTYPES
306 void Fun13(struct struct13 foo13)
307 #else
308 void Fun13(foo13)
309 struct struct13 foo13;
310 #endif
311 {
312 L13 = foo13;
313 }
314 #ifdef PROTOTYPES
315 void Fun14(struct struct14 foo14)
316 #else
317 void Fun14(foo14)
318 struct struct14 foo14;
319 #endif
320 {
321 L14 = foo14;
322 }
323 #ifdef PROTOTYPES
324 void Fun15(struct struct15 foo15)
325 #else
326 void Fun15(foo15)
327 struct struct15 foo15;
328 #endif
329 {
330 L15 = foo15;
331 }
332 #ifdef PROTOTYPES
333 void Fun16(struct struct16 foo16)
334 #else
335 void Fun16(foo16)
336 struct struct16 foo16;
337 #endif
338 {
339 L16 = foo16;
340 }
341 #ifdef PROTOTYPES
342 void Fun17(struct struct17 foo17)
343 #else
344 void Fun17(foo17)
345 struct struct17 foo17;
346 #endif
347 {
348 L17 = foo17;
349 }
350 #ifdef PROTOTYPES
351 void Fun18(struct struct18 foo18)
352 #else
353 void Fun18(foo18)
354 struct struct18 foo18;
355 #endif
356 {
357 L18 = foo18;
358 }
359
360 zed ()
361 {
362
363 L1.a = L2.a = L3.a = L4.a = L5.a = L6.a = L7.a = L8.a = L9.a = L10.a = L11.a = L12.a = L13.a = L14.a = L15.a = L16.a = L17.a = L18.a = 'Z';
364
365 L2.b = L3.b = L4.b = L5.b = L6.b = L7.b = L8.b = L9.b = L10.b = L11.b = L12.b = L13.b = L14.b = L15.b = L16.b = L17.b = L18.b = 'Z';
366
367 L3.c = L4.c = L5.c = L6.c = L7.c = L8.c = L9.c = L10.c = L11.c = L12.c = L13.c = L14.c = L15.c = L16.c = L17.c = L18.c = 'Z';
368
369 L4.d = L5.d = L6.d = L7.d = L8.d = L9.d = L10.d = L11.d = L12.d = L13.d = L14.d = L15.d = L16.d = L17.d = L18.d = 'Z';
370
371 L5.e = L6.e = L7.e = L8.e = L9.e = L10.e = L11.e = L12.e = L13.e = L14.e = L15.e = L16.e = L17.e = L18.e = 'Z';
372
373 L6.f = L7.f = L8.f = L9.f = L10.f = L11.f = L12.f = L13.f = L14.f = L15.f = L16.f = L17.f = L18.f = 'Z';
374
375 L7.g = L8.g = L9.g = L10.g = L11.g = L12.g = L13.g = L14.g = L15.g = L16.g = L17.g = L18.g = 'Z';
376
377 L8.h = L9.h = L10.h = L11.h = L12.h = L13.h = L14.h = L15.h = L16.h = L17.h = L18.h = 'Z';
378
379 L9.i = L10.i = L11.i = L12.i = L13.i = L14.i = L15.i = L16.i = L17.i = L18.i = 'Z';
380
381 L10.j = L11.j = L12.j = L13.j = L14.j = L15.j = L16.j = L17.j = L18.j = 'Z';
382
383 L11.k = L12.k = L13.k = L14.k = L15.k = L16.k = L17.k = L18.k = 'Z';
384
385 L12.l = L13.l = L14.l = L15.l = L16.l = L17.l = L18.l = 'Z';
386
387 L13.m = L14.m = L15.m = L16.m = L17.m = L18.m = 'Z';
388
389 L14.n = L15.n = L16.n = L17.n = L18.n = 'Z';
390
391 L15.o = L16.o = L17.o = L18.o = 'Z';
392
393 L16.p = L17.p = L18.p = 'Z';
394
395 L17.q = L18.q = 'Z';
396
397 L18.r = 'Z';
398 }
399
400 static struct { char c; } chartest[256];
401
402 int main()
403 {
404 #ifdef usestubs
405 set_debug_traps();
406 breakpoint();
407 #endif
408 int i;
409
410 for (i = 0; i < 256; i++)
411 chartest[i].c = i;
412 chartest[0].c = 0; /* chartest-done */
413
414 Fun1(foo1);
415 Fun2(foo2);
416 Fun3(foo3);
417 Fun4(foo4);
418 Fun5(foo5);
419 Fun6(foo6);
420 Fun7(foo7);
421 Fun8(foo8);
422 Fun9(foo9);
423 Fun10(foo10);
424 Fun11(foo11);
425 Fun12(foo12);
426 Fun13(foo13);
427 Fun14(foo14);
428 Fun15(foo15);
429 Fun16(foo16);
430 Fun17(foo17);
431 Fun18(foo18);
432
433 /* An infinite loop that first clears all the variables and then
434 calls each function. This "hack" is to make testing random
435 functions easier - "advance funN" is guaranteed to have always
436 been preceded by a global variable clearing zed call. */
437
438 while (1)
439 {
440 zed ();
441 L1 = fun1();
442 L2 = fun2();
443 L3 = fun3();
444 L4 = fun4();
445 L5 = fun5();
446 L6 = fun6();
447 L7 = fun7();
448 L8 = fun8();
449 L9 = fun9();
450 L10 = fun10();
451 L11 = fun11();
452 L12 = fun12();
453 L13 = fun13();
454 L14 = fun14();
455 L15 = fun15();
456 L16 = fun16();
457 L17 = fun17();
458 L18 = fun18();
459 }
460
461 return 0;
462 }
This page took 0.041145 seconds and 4 git commands to generate.