Debian Codegraph @

gcc/testsuite/gcc.target/csky/fnargs-2.c

raw
1 /* { dg-do run } */
2
3 /* Check that varargs passed partially in registers and
4 partially on the stack works. */
5
6 #include <stdlib.h>
7 #include <string.h>
8 #include <stdarg.h>
9
10 struct s {
11 unsigned int i;
12 double d;
13 char s[16];
14 };
15
16 /* Note specifically that, as there are 4 argument registers,
17 the value of ss.d is split between the last argument register
18 and the stack. */
19 void
20 f (struct s *sp, ...)
21 {
22 int j, k;
23 unsigned int i;
24 double d;
25 char *s;
26 va_list ap;
27 va_start (ap, sp);
28 j = va_arg (ap, int);
29 i = va_arg (ap, unsigned int);
30 d = va_arg (ap, double);
31 s = va_arg (ap, char *);
32 k = va_arg (ap, int);
33 va_end (ap);
34
35 if (sp->i != i
36 || sp->d != d
37 || strcmp (sp->s, s))
38 abort ();
39 if (j != -k)
40 abort ();
41 }
42
43 int
44 main (void)
45 {
46 struct s ss;
47 ss.i = 0xdeadbeef;
48 ss.d = 2.71828;
49 strcpy (ss.s, "shazam!");
50 f (&ss, 42, ss.i, ss.d, ss.s, -42);
51 return 0;
52 }