* gdb.base/help.exp: Remove testing of individual command help text,
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / funcargs.c
CommitLineData
c906108c
SS
1/* Test passing of arguments to functions. Use various sorts of arguments,
2 including basic types, pointers to those types, structures, lots of
3 args, etc, in various combinations. */
4
5/* AIX requires this to be the first thing in the file. */
6#ifdef __GNUC__
7# define alloca __builtin_alloca
8# define HAVE_STACK_ALLOCA 1
9#else /* not __GNUC__ */
10# ifdef _AIX
11 #pragma alloca
12# define HAVE_STACK_ALLOCA 1
13# else /* Not AIX */
14# ifdef sparc
15# include <alloca.h>
16# define HAVE_STACK_ALLOCA 1
17# ifdef __STDC__
18 void *alloca ();
19# else
20 char *alloca ();
21# endif /* __STDC__ */
22# endif /* sparc */
23# endif /* Not AIX */
24#endif /* not __GNUC__ */
25
26char c = 'a';
27char *cp = &c;
28
29unsigned char uc = 'b';
30unsigned char *ucp = &uc;
31
32short s = 1;
33short *sp = &s;
34
35unsigned short us = 6;
36unsigned short *usp = &us;
37
38int i = 2;
39int *ip = &i;
40
41unsigned int ui = 7;
42unsigned int *uip = &ui;
43
44long l = 3;
45long *lp = &l;
46
47unsigned long ul = 8;
48unsigned long *ulp = &ul;
49
50float f = 4.0;
51float *fp = &f;
52
53double d = 5.0;
54double *dp = &d;
55
e43ec454
YQ
56#ifdef TEST_COMPLEX
57float _Complex fc = 1.0F + 2.0iF;
58double _Complex dc = 3.0 + 4.0i;
59long double _Complex ldc = 5.0L + 6.0iL;
60#endif /* TEST_COMPLEX */
61
c906108c
SS
62struct stag {
63 int s1;
64 int s2;
65} st = { 101, 102 };
66struct stag *stp = &st;
67
68union utag {
69 int u1;
70 long u2;
71} un;
72union utag *unp = &un;
73
74char carray[] = {'a', 'n', ' ', 'a', 'r', 'r', 'a', 'y', '\0'};
75
76
77/* Test various permutations and interleaving of integral arguments */
78
79
085dd6e6
JM
80#ifdef PROTOTYPES
81void call0a (char c, short s, int i, long l)
82#else
c906108c
SS
83call0a (c, s, i, l)
84char c; short s; int i; long l;
085dd6e6 85#endif
c906108c
SS
86{
87 c = 'a';
88 s = 5;
89 i = 6;
90 l = 7;
91}
92
085dd6e6
JM
93#ifdef PROTOTYPES
94void call0b (short s, int i, long l, char c)
95#else
c906108c
SS
96call0b (s, i, l, c)
97short s; int i; long l; char c;
085dd6e6 98#endif
c906108c
SS
99{
100 s = 6; i = 7; l = 8; c = 'j';
101}
102
085dd6e6
JM
103#ifdef PROTOTYPES
104void call0c (int i, long l, char c, short s)
105#else
c906108c
SS
106call0c (i, l, c, s)
107int i; long l; char c; short s;
085dd6e6 108#endif
c906108c
SS
109{
110 i = 3; l = 4; c = 'k'; s = 5;
111}
112
085dd6e6
JM
113#ifdef PROTOTYPES
114void call0d (long l, char c, short s, int i)
115#else
c906108c
SS
116call0d (l, c, s, i)
117long l; char c; short s; int i;
085dd6e6 118#endif
c906108c
SS
119{
120 l = 7; c = 'z'; s = 8; i = 9;
121}
122
085dd6e6
JM
123#ifdef PROTOTYPES
124void call0e (char c1, long l, char c2, int i, char c3, short s, char c4, char c5)
125#else
c906108c
SS
126call0e (c1, l, c2, i, c3, s, c4, c5)
127char c1; long l; char c2; int i; char c3; short s; char c4; char c5;
085dd6e6 128#endif
c906108c
SS
129{
130 c1 = 'a'; l = 5; c2 = 'b'; i = 7; c3 = 'c'; s = 7; c4 = 'f'; c5 = 'g';
131}
132
133
134/* Test various permutations and interleaving of unsigned integral arguments */
135
136
085dd6e6
JM
137#ifdef PROTOTYPES
138void call1a (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
139#else
c906108c
SS
140call1a (uc, us, ui, ul)
141unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
085dd6e6 142#endif
c906108c
SS
143{
144 uc = 5; us = 6; ui = 7; ul = 8;
145}
146
085dd6e6
JM
147#ifdef PROTOTYPES
148void call1b (unsigned short us, unsigned int ui, unsigned long ul, unsigned char uc)
149#else
c906108c
SS
150call1b (us, ui, ul, uc)
151unsigned short us; unsigned int ui; unsigned long ul; unsigned char uc;
085dd6e6 152#endif
c906108c
SS
153{
154 uc = 5; us = 6; ui = 7; ul = 8;
155}
156
085dd6e6
JM
157#ifdef PROTOTYPES
158void call1c (unsigned int ui, unsigned long ul, unsigned char uc, unsigned short us)
159#else
c906108c
SS
160call1c (ui, ul, uc, us)
161unsigned int ui; unsigned long ul; unsigned char uc; unsigned short us;
085dd6e6 162#endif
c906108c
SS
163{
164 uc = 5; us = 6; ui = 7; ul = 8;
165}
166
085dd6e6
JM
167#ifdef PROTOTYPES
168void call1d (unsigned long ul, unsigned char uc, unsigned short us, unsigned int ui)
169#else
c906108c
SS
170call1d (ul, uc, us, ui)
171unsigned long ul; unsigned char uc; unsigned short us; unsigned int ui;
085dd6e6 172#endif
c906108c
SS
173{
174 uc = 5; us = 6; ui = 7; ul = 8;
175}
176
085dd6e6
JM
177#ifdef PROTOTYPES
178void call1e (unsigned char uc1, unsigned long ul, unsigned char uc2, unsigned int ui, unsigned char uc3, unsigned short us, unsigned char uc4, unsigned char uc5)
179#else
c906108c
SS
180call1e (uc1, ul, uc2, ui, uc3, us, uc4, uc5)
181unsigned char uc1; unsigned long ul; unsigned char uc2; unsigned int ui;
182unsigned char uc3; unsigned short us; unsigned char uc4; unsigned char uc5;
085dd6e6 183#endif
c906108c
SS
184{
185 uc1 = 5; ul = 7; uc2 = 8; ui = 9; uc3 = 10; us = 11; uc4 = 12; uc5 = 55;
186}
187
188/* Test various permutations and interleaving of integral arguments with
189 floating point arguments. */
190
191
085dd6e6
JM
192#ifdef PROTOTYPES
193void call2a (char c, float f1, short s, double d1, int i, float f2, long l, double d2)
194#else
c906108c
SS
195call2a (c, f1, s, d1, i, f2, l, d2)
196char c; float f1; short s; double d1; int i; float f2; long l; double d2;
085dd6e6 197#endif
c906108c
SS
198{
199 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
200}
201
085dd6e6
JM
202#ifdef PROTOTYPES
203void call2b (float f1, short s, double d1, int i, float f2, long l, double d2, char c)
204#else
c906108c
SS
205call2b (f1, s, d1, i, f2, l, d2, c)
206float f1; short s; double d1; int i; float f2; long l; double d2; char c;
085dd6e6 207#endif
c906108c
SS
208{
209 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
210}
211
085dd6e6
JM
212#ifdef PROTOTYPES
213void call2c (short s, double d1, int i, float f2, long l, double d2, char c, float f1)
214#else
c906108c
SS
215call2c (s, d1, i, f2, l, d2, c, f1)
216short s; double d1; int i; float f2; long l; double d2; char c; float f1;
085dd6e6 217#endif
c906108c
SS
218{
219 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
220}
221
085dd6e6
JM
222#ifdef PROTOTYPES
223void call2d (double d1, int i, float f2, long l, double d2, char c, float f1, short s)
224#else
c906108c
SS
225call2d (d1, i, f2, l, d2, c, f1, s)
226double d1; int i; float f2; long l; double d2; char c; float f1; short s;
085dd6e6 227#endif
c906108c
SS
228{
229 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
230}
231
085dd6e6
JM
232#ifdef PROTOTYPES
233void call2e (int i, float f2, long l, double d2, char c, float f1, short s, double d1)
234#else
c906108c
SS
235call2e (i, f2, l, d2, c, f1, s, d1)
236int i; float f2; long l; double d2; char c; float f1; short s; double d1;
085dd6e6 237#endif
c906108c
SS
238{
239 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
240}
241
085dd6e6
JM
242#ifdef PROTOTYPES
243void call2f (float f2, long l, double d2, char c, float f1, short s, double d1, int i)
244#else
c906108c
SS
245call2f (f2, l, d2, c, f1, s, d1, i)
246float f2; long l; double d2; char c; float f1; short s; double d1; int i;
085dd6e6 247#endif
c906108c
SS
248{
249 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
250}
251
085dd6e6
JM
252#ifdef PROTOTYPES
253void call2g (long l, double d2, char c, float f1, short s, double d1, int i, float f2)
254#else
c906108c
SS
255call2g (l, d2, c, f1, s, d1, i, f2)
256long l; double d2; char c; float f1; short s; double d1; int i; float f2;
085dd6e6 257#endif
c906108c
SS
258{
259 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
260}
261
085dd6e6
JM
262#ifdef PROTOTYPES
263void call2h (double d2, char c, float f1, short s, double d1, int i, float f2, long l)
264#else
c906108c
SS
265call2h (d2, c, f1, s, d1, i, f2, l)
266double d2; char c; float f1; short s; double d1; int i; float f2; long l;
085dd6e6 267#endif
c906108c
SS
268{
269 c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;
270}
271
085dd6e6
JM
272#ifdef PROTOTYPES
273void call2i (char c1, float f1, char c2, char c3, double d1, char c4, char c5, char c6, float f2, short s, char c7, double d2)
274#else
c906108c
SS
275call2i (c1, f1, c2, c3, d1, c4, c5, c6, f2, s, c7, d2)
276char c1; float f1; char c2; char c3; double d1; char c4; char c5; char c6;
277float f2; short s; char c7; double d2;
085dd6e6 278#endif
c906108c
SS
279{
280 c1 = 'a'; f1 = 0.0; c2 = 5; d1 = 0.0; c3 = 6; f2 = 0.1; c4 = 7; d2 = 0.2;
281 c5 = 's'; c6 = 'f'; c7 = 'z'; s = 77;
282}
283
284
285/* Test pointers to various integral and floating types. */
286
287
085dd6e6
JM
288#ifdef PROTOTYPES
289void call3a (char *cp, short *sp, int *ip, long *lp)
290#else
c906108c
SS
291call3a (cp, sp, ip, lp)
292char *cp; short *sp; int *ip; long *lp;
085dd6e6 293#endif
c906108c
SS
294{
295 cp = 0; sp = 0; ip = 0; lp = 0;
296}
297
085dd6e6
JM
298#ifdef PROTOTYPES
299void call3b (unsigned char *ucp, unsigned short *usp, unsigned int *uip, unsigned long *ulp)
300#else
c906108c
SS
301call3b (ucp, usp, uip, ulp)
302unsigned char *ucp; unsigned short *usp; unsigned int *uip;
303unsigned long *ulp;
085dd6e6 304#endif
c906108c
SS
305{
306 ucp = 0; usp = 0; uip = 0; ulp = 0;
307}
308
085dd6e6
JM
309#ifdef PROTOTYPES
310void call3c (float *fp, double *dp)
311#else
c906108c
SS
312call3c (fp, dp)
313float *fp; double *dp;
085dd6e6 314#endif
c906108c
SS
315{
316 fp = 0; dp = 0;
317}
318
319
e43ec454
YQ
320
321#ifdef TEST_COMPLEX
322
323/* Test various _Complex type args. */
324
325#ifdef PROTOTYPES
326void callca (float _Complex f1, float _Complex f2, float _Complex f3)
327#else
328callca (f1, f2, f3)
329float _Complex f1; float _Complex f2; float _Complex f3;
330#endif
331{
332
333}
334
335#ifdef PROTOTYPES
336void callcb (double _Complex d1, double _Complex d2, double _Complex d3)
337#else
338callcb (d1, d2, d3)
339double _Complex d1; double _Complex d2; double _Complex d3;
340#endif
341{
342
343}
344
345#ifdef PROTOTYPES
346void callcc (long double _Complex ld1, long double _Complex ld2, long double _Complex ld3)
347#else
348callcc (ld1, ld2, ld3)
349long double _Complex ld1; long double _Complex ld2; long double _Complex ld3;
350#endif
351{
352
353}
354
355#ifdef PROTOTYPES
356void callcd (float _Complex fc1, double _Complex dc1, long double _Complex ldc1)
357#else
358callcd (fc1, dc1, ldc1)
359float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
360#endif
361{
362}
363
364#ifdef PROTOTYPES
365void callce (double _Complex dc1, long double _Complex ldc1, float _Complex fc1)
366#else
367callce (dc1, ldc1, fc1)
368double _Complex dc1; long double _Complex ldc1; float _Complex fc1;
369#endif
370{
371}
372
373#ifdef PROTOTYPES
374void callcf (long double _Complex ldc1, float _Complex fc1, double _Complex dc1)
375#else
376callcf (ldc1, fc1, dc1)
377long double _Complex ldc1; float _Complex fc1; double _Complex dc1;
378#endif
379{
380}
381
382
383/* Test passing _Complex type and integral. */
384#ifdef PROTOTYPES
385void callc1a (char c, short s, int i, unsigned int ui, long l,
386 float _Complex fc1, double _Complex dc1,
387 long double _Complex ldc1)
388#else
389callc1a (c, s, i, ui, l, fc1, dc1, ldc1)
390char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
391#endif
392{}
393
394#ifdef PROTOTYPES
395void callc1b (long double _Complex ldc1, char c, short s, int i,
396 float _Complex fc1, unsigned int ui, long l, double _Complex dc1)
397#else
398callc1b (ldc1, c, s, i, fc1, ui, l, dc1)
399char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
400#endif
401{}
402
403
404#ifdef PROTOTYPES
405void callc2a (char c, short s, int i, unsigned int ui, long l, float f,
406 double d, float _Complex fc1, double _Complex dc1,
407 long double _Complex ldc1)
408#else
409callc2a (c, s, i, ui, l, f, d, fc1, dc1, ldc1)
410 char c; short s; int i; unsigned int ui; long l; float f; double d;
411 float _Complex fc1; double _Complex dc1;
412 long double _Complex ldc1;
413#endif
414{}
415
416#ifdef PROTOTYPES
417void callc2b (float _Complex fc1, char c, short s, int i, unsigned int ui,
418 long double _Complex ldc1, long l, float f, double d,
419 double _Complex dc1)
420#else
421callc2b (fc1, c, s, i, ui, ldc1, l, f, d, dc1)
422 char c; short s; int i; unsigned int ui; long l; float f; double d;
423 float _Complex fc1; double _Complex dc1;
424 long double _Complex ldc1;
425#endif
426{}
427
428
429#endif /* TEST_COMPLEX */
430
c906108c
SS
431/* Test passing structures and unions by reference. */
432
433
085dd6e6
JM
434#ifdef PROTOTYPES
435void call4a (struct stag *stp)
436#else
c906108c 437call4a (stp)
085dd6e6
JM
438struct stag *stp;
439#endif
440{stp = 0;}
c906108c 441
085dd6e6
JM
442#ifdef PROTOTYPES
443void call4b (union utag *unp)
444#else
c906108c
SS
445call4b (unp)
446union utag *unp;
085dd6e6 447#endif
c906108c
SS
448{
449 unp = 0;
450}
451
452
453/* Test passing structures and unions by value. */
454
455
085dd6e6
JM
456#ifdef PROTOTYPES
457void call5a (struct stag st)
458#else
c906108c 459call5a (st)
085dd6e6
JM
460struct stag st;
461#endif
462{st.s1 = 5;}
c906108c 463
085dd6e6
JM
464#ifdef PROTOTYPES
465void call5b (union utag un)
466#else
c906108c 467call5b (un)
085dd6e6
JM
468union utag un;
469#endif
470{un.u1 = 7;}
c906108c
SS
471
472
473/* Test shuffling of args */
474
475
085dd6e6 476void call6k ()
c906108c 477{
c906108c
SS
478}
479
085dd6e6
JM
480#ifdef PROTOTYPES
481void call6j (unsigned long ul)
482#else
483call6j (ul)
484unsigned long ul;
485#endif
c906108c 486{
085dd6e6
JM
487 ul = ul;
488 call6k ();
c906108c
SS
489}
490
085dd6e6
JM
491#ifdef PROTOTYPES
492void call6i (unsigned int ui, unsigned long ul)
493#else
494call6i (ui, ul)
495unsigned int ui; unsigned long ul;
496#endif
c906108c 497{
085dd6e6
JM
498 ui = ui;
499 call6j (ul);
c906108c
SS
500}
501
085dd6e6
JM
502#ifdef PROTOTYPES
503void call6h (unsigned short us, unsigned int ui, unsigned long ul)
504#else
505call6h (us, ui, ul)
506unsigned short us; unsigned int ui; unsigned long ul;
507#endif
c906108c 508{
085dd6e6
JM
509 us = us;
510 call6i (ui, ul);
c906108c
SS
511}
512
085dd6e6
JM
513#ifdef PROTOTYPES
514void call6g (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
515#else
516call6g (uc, us, ui, ul)
c906108c 517unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
085dd6e6 518#endif
c906108c 519{
085dd6e6
JM
520 uc = uc;
521 call6h (us, ui, ul);
c906108c
SS
522}
523
085dd6e6
JM
524#ifdef PROTOTYPES
525void call6f (double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
526#else
c906108c
SS
527call6f (d, uc, us, ui, ul)
528double d;
529unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
085dd6e6 530#endif
c906108c
SS
531{
532 d = d;
533 call6g (uc, us, ui, ul);
534}
535
085dd6e6
JM
536#ifdef PROTOTYPES
537void call6e (float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
538#else
539call6e (f, d, uc, us, ui, ul)
540float f; double d;
c906108c 541unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
085dd6e6 542#endif
c906108c 543{
085dd6e6
JM
544 f = f;
545 call6f (d, uc, us, ui, ul);
c906108c
SS
546}
547
085dd6e6
JM
548#ifdef PROTOTYPES
549void call6d (long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
550#else
551call6d (l, f, d, uc, us, ui, ul)
552long l; float f; double d;
553unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
554#endif
c906108c 555{
085dd6e6
JM
556 l = l;
557 call6e (f, d, uc, us, ui, ul);
c906108c
SS
558}
559
085dd6e6
JM
560#ifdef PROTOTYPES
561void call6c (int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
562#else
563call6c (i, l, f, d, uc, us, ui, ul)
564int i; long l; float f; double d;
565unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
566#endif
c906108c 567{
085dd6e6
JM
568 i = i;
569 call6d (l, f, d, uc, us, ui, ul);
c906108c
SS
570}
571
085dd6e6
JM
572#ifdef PROTOTYPES
573void call6b (short s, int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
574#else
575call6b (s, i, l, f, d, uc, us, ui, ul)
576short s; int i; long l; float f; double d;
577unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
578#endif
c906108c 579{
085dd6e6
JM
580 s = s;
581 call6c (i, l, f, d, uc, us, ui, ul);
c906108c
SS
582}
583
085dd6e6
JM
584#ifdef PROTOTYPES
585void call6a (char c, short s, int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
586#else
587call6a (c, s, i, l, f, d, uc, us, ui, ul)
588char c; short s; int i; long l; float f; double d;
589unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;
590#endif
c906108c 591{
085dd6e6
JM
592 c = c;
593 call6b (s, i, l, f, d, uc, us, ui, ul);
c906108c
SS
594}
595
c906108c
SS
596/* Test shuffling of args, round robin */
597
598
085dd6e6
JM
599#ifdef PROTOTYPES
600void call7k (char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui)
601#else
602call7k (c, i, s, l, f, uc, d, us, ul, ui)
c906108c 603char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui;
085dd6e6 604#endif
c906108c 605{
085dd6e6
JM
606 c = 'a'; i = 7; s = 8; l = 7; f = 0.3; uc = 44; d = 0.44; us = 77;
607 ul = 43; ui = 33;
c906108c
SS
608}
609
085dd6e6
JM
610#ifdef PROTOTYPES
611void call7j (unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul)
612#else
613call7j (ui, c, i, s, l, f, uc, d, us, ul)
614unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul;
615#endif
c906108c 616{
085dd6e6 617 call7k (c, i, s, l, f, uc, d, us, ul, ui);
c906108c
SS
618}
619
085dd6e6
JM
620#ifdef PROTOTYPES
621void call7i (unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us)
622#else
623call7i (ul, ui, c, i, s, l, f, uc, d, us)
624unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us;
625#endif
c906108c 626{
085dd6e6 627 call7j (ui, c, i, s, l, f, uc, d, us, ul);
c906108c
SS
628}
629
085dd6e6
JM
630#ifdef PROTOTYPES
631void call7h (unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d)
632#else
633call7h (us, ul, ui, c, i, s, l, f, uc, d)
634unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d;
635#endif
c906108c 636{
085dd6e6 637 call7i (ul, ui, c, i, s, l, f, uc, d, us);
c906108c
SS
638}
639
085dd6e6
JM
640#ifdef PROTOTYPES
641void call7g (double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc)
642#else
643call7g (d, us, ul, ui, c, i, s, l, f, uc)
644double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc;
645#endif
c906108c 646{
085dd6e6 647 call7h (us, ul, ui, c, i, s, l, f, uc, d);
c906108c
SS
648}
649
085dd6e6
JM
650#ifdef PROTOTYPES
651void call7f (unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f)
652#else
c906108c
SS
653call7f (uc, d, us, ul, ui, c, i, s, l, f)
654unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f;
085dd6e6 655#endif
c906108c
SS
656{
657 call7g (d, us, ul, ui, c, i, s, l, f, uc);
658}
659
085dd6e6
JM
660#ifdef PROTOTYPES
661void call7e (float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l)
662#else
663call7e (f, uc, d, us, ul, ui, c, i, s, l)
664float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l;
665#endif
c906108c 666{
085dd6e6 667 call7f (uc, d, us, ul, ui, c, i, s, l, f);
c906108c
SS
668}
669
085dd6e6
JM
670#ifdef PROTOTYPES
671void call7d (long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s)
672#else
673call7d (l, f, uc, d, us, ul, ui, c, i, s)
674long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s;
675#endif
c906108c 676{
085dd6e6 677 call7e (f, uc, d, us, ul, ui, c, i, s, l);
c906108c
SS
678}
679
085dd6e6
JM
680#ifdef PROTOTYPES
681void call7c (short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i)
682#else
683call7c (s, l, f, uc, d, us, ul, ui, c, i)
684short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i;
685#endif
c906108c 686{
085dd6e6 687 call7d (l, f, uc, d, us, ul, ui, c, i, s);
c906108c
SS
688}
689
085dd6e6
JM
690#ifdef PROTOTYPES
691void call7b (int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c)
692#else
693call7b (i, s, l, f, uc, d, us, ul, ui, c)
694int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c;
695#endif
c906108c 696{
085dd6e6 697 call7c (s, l, f, uc, d, us, ul, ui, c, i);
c906108c
SS
698}
699
085dd6e6
JM
700#ifdef PROTOTYPES
701void call7a (char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui)
702#else
703call7a (c, i, s, l, f, uc, d, us, ul, ui)
c906108c 704char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui;
085dd6e6 705#endif
c906108c 706{
085dd6e6 707 call7b (i, s, l, f, uc, d, us, ul, ui, c);
c906108c
SS
708}
709
710
711/* Test printing of structures passed as arguments to recursive functions. */
712
713
714typedef struct s
715{
716 short s;
717 int i;
718 long l;
719} SVAL;
720
085dd6e6 721void hitbottom ()
c906108c
SS
722{
723}
724
085dd6e6
JM
725#ifdef PROTOTYPES
726void recurse (SVAL a, int depth)
727#else
c906108c
SS
728void recurse (a, depth)
729SVAL a;
730int depth;
085dd6e6 731#endif
c906108c
SS
732{
733 a.s = a.i = a.l = --depth;
734 if (depth == 0)
735 hitbottom ();
736 else
737 recurse (a, depth);
738}
739
085dd6e6 740void test_struct_args ()
c906108c
SS
741{
742 SVAL s; s.s = 5; s.i = 5; s.l = 5;
743
744 recurse (s, 5);
745}
746
747/* On various machines (pa, 29k, and rs/6000, at least), a function which
748 calls alloca may do things differently with respect to frames. So give
749 it a try. */
750
085dd6e6
JM
751#ifdef PROTOTYPES
752void localvars_after_alloca (char c, short s, int i, long l)
753#else
9a81ba51 754void
c906108c
SS
755localvars_after_alloca (c, s, i, l)
756 char c;
757 short s;
758 int i;
759 long l;
085dd6e6 760#endif
c906108c
SS
761{
762#ifdef HAVE_STACK_ALLOCA
763 /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't
764 test what we are looking for, so if we don't have an alloca which
765 allocates on the stack, just don't bother to call alloca at all. */
766
767 char *z = alloca (s + 50);
768#endif
769 c = 'a';
770 s = 5;
771 i = 6;
772 l = 7;
773}
774
085dd6e6
JM
775#ifdef PROTOTYPES
776void call_after_alloca_subr (char c, short s, int i, long l, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)
777#else
c906108c
SS
778void
779call_after_alloca_subr (c, s, i, l, uc, us, ui, ul)
780char c; int i; short s; long l; unsigned char uc; unsigned short us; unsigned long ul; unsigned int ui;
085dd6e6 781#endif
c906108c
SS
782{
783 c = 'a';
784 i = 7; s = 8; l = 7; uc = 44; us = 77;
785 ul = 43; ui = 33;
786}
787
085dd6e6
JM
788#ifdef PROTOTYPES
789void call_after_alloca (char c, short s, int i, long l)
790#else
9a81ba51 791void
c906108c
SS
792call_after_alloca (c, s, i, l)
793 char c;
794 short s;
795 int i;
796 long l;
085dd6e6 797#endif
c906108c
SS
798{
799#ifdef HAVE_STACK_ALLOCA
800 /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't
801 test what we are looking for, so if we don't have an alloca which
802 allocates on the stack, just don't bother to call alloca at all. */
803
804 char *z = alloca (s + 50);
805#endif
806 call_after_alloca_subr (c, s, i, l, 'b', 11, 12, (unsigned long)13);
807}
808
809\f
810
811/* The point behind this test is the PA will call this indirectly
812 through dyncall. Unlike the indirect calls to call0a, this test
813 will require a trampoline between dyncall and this function on the
814 call path, then another trampoline on between this function and main
815 on the return path. */
085dd6e6
JM
816#ifdef PROTOTYPES
817double call_with_trampolines (double d1)
818#else
c906108c
SS
819double
820call_with_trampolines (d1)
821double d1;
085dd6e6 822#endif
c906108c
SS
823{
824 return d1;
825} /* End of call_with_trampolines, this comment is needed by funcargs.exp */
826
827/* Dummy functions which the testsuite can use to run to, etc. */
828
829void
830marker_indirect_call () {}
831
832void
833marker_call_with_trampolines () {}
834\f
085dd6e6 835int main ()
c906108c 836{
085dd6e6
JM
837 void (*pointer_to_call0a) (char, short, int, long) = (void (*)(char, short, int, long))call0a;
838 double (*pointer_to_call_with_trampolines) (double) = call_with_trampolines;
c906108c 839
c906108c
SS
840 /* Test calling with basic integer types */
841 call0a (c, s, i, l);
842 call0b (s, i, l, c);
843 call0c (i, l, c, s);
844 call0d (l, c, s, i);
845 call0e (c, l, c, i, c, s, c, c);
846
847 /* Test calling with unsigned integer types */
848 call1a (uc, us, ui, ul);
849 call1b (us, ui, ul, uc);
850 call1c (ui, ul, uc, us);
851 call1d (ul, uc, us, ui);
852 call1e (uc, ul, uc, ui, uc, us, uc, uc);
853
854 /* Test calling with integral types mixed with floating point types */
855 call2a (c, f, s, d, i, f, l, d);
856 call2b (f, s, d, i, f, l, d, c);
857 call2c (s, d, i, f, l, d, c, f);
858 call2d (d, i, f, l, d, c, f, s);
859 call2e (i, f, l, d, c, f, s, d);
860 call2f (f, l, d, c, f, s, d, i);
861 call2g (l, d, c, f, s, d, i, f);
862 call2h (d, c, f, s, d, i, f, l);
04c12f60 863 call2i (c, f, c, c, d, c, c, c, f, s, c, d);
c906108c 864
e43ec454
YQ
865#ifdef TEST_COMPLEX
866 /* Test calling with _Complex types. */
867 callca (fc, fc, fc);
868 callcb (dc, dc, dc);
869 callcc (ldc, ldc, ldc);
870 callcd (fc, dc, ldc);
871 callce (dc, ldc, fc);
872 callcf (ldc, fc, dc);
873
874
875 callc1a (c, s, i, ui, l, fc, dc, ldc);
876 callc1b (ldc, c, s, i, fc, ui, l, dc);
877
878 callc2a (c, s, i, ui, l, f, d, fc, dc, ldc);
879 callc2b (fc, c, s, i, ui, ldc, l, f, d, dc);
880#endif /* TEST_COMPLEX */
881
c906108c
SS
882 /* Test dereferencing pointers to various integral and floating types */
883
884 call3a (cp, sp, ip, lp);
885 call3b (ucp, usp, uip, ulp);
886 call3c (fp, dp);
887
888 /* Test dereferencing pointers to structs and unions */
889
890 call4a (stp);
891 un.u1 = 1;
892 call4b (unp);
893
894 /* Test calling with structures and unions. */
895
896 call5a (st);
897 un.u1 = 2;
898 call5b (un);
899
900 /* Test shuffling of args */
901
902 call6a (c, s, i, l, f, d, uc, us, ui, ul);
903 call7a (c, i, s, l, f, uc, d, us, ul, ui);
904
905 /* Test passing structures recursively. */
906
907 test_struct_args ();
908
909 localvars_after_alloca (c, s, i, l);
910
911 call_after_alloca (c, s, i, l);
912
913 /* This is for localvars_in_indirect_call. */
914 marker_indirect_call ();
915 /* The comment on the following two lines is used by funcargs.exp,
916 don't change it. */
917 (*pointer_to_call0a) (c, s, i, l); /* First step into call0a. */
918 (*pointer_to_call0a) (c, s, i, l); /* Second step into call0a. */
919 marker_call_with_trampolines ();
920 (*pointer_to_call_with_trampolines) (d); /* Test multiple trampolines. */
085dd6e6 921 return 0;
c906108c 922}
This page took 1.225671 seconds and 4 git commands to generate.