2 Purpose: Test passing struct in variable argument lists.
5 Originator: ARM Ltd. */
8 /* { dg-output "" { xfail avr32*-*-* } } */
28 static struct large_tag
37 s1
= va_arg (ap
, struct small_tag
);
38 l
= va_arg (ap
, struct large_tag
);
39 s2
= va_arg (ap
, struct small_tag
);
40 printf ("%u %u %u %u %u %u %u %u %u\n", s1
.a
, s1
.b
, l
.a
, l
.b
, l
.c
, l
.d
, l
.e
,
55 ffi_type
* arg_types
[5];
58 ffi_type
*s_type_elements
[3];
61 ffi_type
*l_type_elements
[6];
72 s_type
.type
= FFI_TYPE_STRUCT
;
73 s_type
.elements
= s_type_elements
;
75 s_type_elements
[0] = &ffi_type_uchar
;
76 s_type_elements
[1] = &ffi_type_uchar
;
77 s_type_elements
[2] = NULL
;
81 l_type
.type
= FFI_TYPE_STRUCT
;
82 l_type
.elements
= l_type_elements
;
84 l_type_elements
[0] = &ffi_type_uint
;
85 l_type_elements
[1] = &ffi_type_uint
;
86 l_type_elements
[2] = &ffi_type_uint
;
87 l_type_elements
[3] = &ffi_type_uint
;
88 l_type_elements
[4] = &ffi_type_uint
;
89 l_type_elements
[5] = NULL
;
91 arg_types
[0] = &ffi_type_sint
;
92 arg_types
[1] = &s_type
;
93 arg_types
[2] = &l_type
;
94 arg_types
[3] = &s_type
;
97 CHECK(ffi_prep_cif_var(&cif
, FFI_DEFAULT_ABI
, 1, 4, &l_type
, arg_types
) == FFI_OK
);
119 ffi_call(&cif
, FFI_FN(test_fn
), &res
, args
);
120 /* { dg-output "5 6 10 11 12 13 14 7 8" } */
121 printf("res: %d %d %d %d %d\n", res
.a
, res
.b
, res
.c
, res
.d
, res
.e
);
122 /* { dg-output "\nres: 15 17 19 21 14" } */