1/* PR target/12503 */ 2/* Origin: <pierre.nguyen-tuong@asim.lip6.fr> */ 3 4/* Verify that __builtin_apply behaves correctly on targets 5 with pre-pushed arguments (e.g. SPARC). */ 6 7/* { dg-do run } */ 8 9/* arm_hf_eabi: Variadic funcs use Base AAPCS. Normal funcs use VFP variant. 10 avr: Variadic funcs don't pass arguments in registers, while normal funcs 11 do. */ 12/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs" { arm_hf_eabi || { avr-*-* } } "*" "" } */ 13/* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args in registers." { nds32*-*-* } "*" "" } */ 14/* { dg-require-effective-target untyped_assembly } */ 15 16 17#define INTEGER_ARG 5 18 19#if defined(__ARM_PCS) || defined(__epiphany__) 20/* For Base AAPCS, NAME is passed in r0. D is passed in r2 and r3. 21 E, F and G are passed on stack. So the size of the stack argument 22 data is 20. */ 23#define STACK_ARGUMENTS_SIZE 20 24#elif defined __aarch64__ || defined __arc__ || defined __MMIX__ 25/* No parameters on stack for bar. */ 26#define STACK_ARGUMENTS_SIZE 0 27#else 28#define STACK_ARGUMENTS_SIZE 64 29#endif 30 31extern void abort(void); 32 33void foo(char *name, double d, double e, double f, int g) 34{ 35 if (g != INTEGER_ARG) 36 abort(); 37} 38 39void bar(char *name, ...) 40{ 41 __builtin_apply(foo, __builtin_apply_args(), STACK_ARGUMENTS_SIZE); 42} 43 44int main(void) 45{ 46 bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG); 47 48 return 0; 49} 50