OSDN Git Service

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