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