2 Purpose: Test passing struct in variable argument lists.
5 Originator: ARM Ltd. */
8 /* { dg-output "" { xfail avr32*-*-* } } */
47 s1
= va_arg (ap
, struct small_tag
);
48 l
= va_arg (ap
, struct large_tag
);
49 s2
= va_arg (ap
, struct small_tag
);
51 uc
= va_arg (ap
, unsigned);
52 sc
= va_arg (ap
, signed);
54 us
= va_arg (ap
, unsigned);
55 ss
= va_arg (ap
, signed);
57 ui
= va_arg (ap
, unsigned int);
58 si
= va_arg (ap
, signed int);
60 ul
= va_arg (ap
, unsigned long);
61 sl
= va_arg (ap
, signed long);
63 f
= va_arg (ap
, double); /* C standard promotes float->double
65 d
= va_arg (ap
, double);
67 printf ("%u %u %u %u %u %u %u %u %u uc=%u sc=%d %u %d %u %d %lu %ld %f %f\n",
68 s1
.a
, s1
.b
, l
.a
, l
.b
, l
.c
, l
.d
, l
.e
,
84 ffi_type
* arg_types
[15];
87 ffi_type
*s_type_elements
[3];
90 ffi_type
*l_type_elements
[6];
111 s_type
.alignment
= 0;
112 s_type
.type
= FFI_TYPE_STRUCT
;
113 s_type
.elements
= s_type_elements
;
115 s_type_elements
[0] = &ffi_type_uchar
;
116 s_type_elements
[1] = &ffi_type_uchar
;
117 s_type_elements
[2] = NULL
;
120 l_type
.alignment
= 0;
121 l_type
.type
= FFI_TYPE_STRUCT
;
122 l_type
.elements
= l_type_elements
;
124 l_type_elements
[0] = &ffi_type_uint
;
125 l_type_elements
[1] = &ffi_type_uint
;
126 l_type_elements
[2] = &ffi_type_uint
;
127 l_type_elements
[3] = &ffi_type_uint
;
128 l_type_elements
[4] = &ffi_type_uint
;
129 l_type_elements
[5] = NULL
;
131 arg_types
[0] = &ffi_type_sint
;
132 arg_types
[1] = &s_type
;
133 arg_types
[2] = &l_type
;
134 arg_types
[3] = &s_type
;
135 arg_types
[4] = &ffi_type_uchar
;
136 arg_types
[5] = &ffi_type_schar
;
137 arg_types
[6] = &ffi_type_ushort
;
138 arg_types
[7] = &ffi_type_sshort
;
139 arg_types
[8] = &ffi_type_uint
;
140 arg_types
[9] = &ffi_type_sint
;
141 arg_types
[10] = &ffi_type_ulong
;
142 arg_types
[11] = &ffi_type_slong
;
143 arg_types
[12] = &ffi_type_double
;
144 arg_types
[13] = &ffi_type_double
;
145 arg_types
[14] = NULL
;
147 CHECK(ffi_prep_cif_var(&cif
, FFI_DEFAULT_ABI
, 1, 14, &ffi_type_sint
, arg_types
) == FFI_OK
);
190 ffi_call(&cif
, FFI_FN(test_fn
), &res
, args
);
191 /* { dg-output "5 6 10 11 12 13 14 7 8 uc=9 sc=10 11 12 13 14 15 16 2.120000 3.130000" } */
192 printf("res: %d\n", (int) res
);
193 /* { dg-output "\nres: 42" } */