variadic_06_mixed.c (689B)
1 /* Mixed integer + double variadic args. AAPCS64 routes ints through the 2 * GP save area and doubles through the FP save area independently — the 3 * caller's argument order doesn't determine the save-slot order, only 4 * the per-class cursor does. Sums in FP to also exercise int→double 5 * usual-arithmetic conversion. */ 6 double mixed(int n, ...) { 7 __builtin_va_list ap; 8 __builtin_va_start(ap, n); 9 int i1 = __builtin_va_arg(ap, int); 10 double d1 = __builtin_va_arg(ap, double); 11 int i2 = __builtin_va_arg(ap, int); 12 double d2 = __builtin_va_arg(ap, double); 13 __builtin_va_end(ap); 14 return i1 + d1 + i2 + d2; 15 } 16 17 int test_main(void) { return (int)mixed(4, 10, 11.0, 9, 12.0); }