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