/* { dg-options "-std=gnu99" } */
|
/* { dg-options "-std=gnu99" } */
|
|
|
/* C99 6.5.2.2 Function calls.
|
/* C99 6.5.2.2 Function calls.
|
Test passing varargs of the combination of decimal float types and
|
Test passing varargs of the combination of decimal float types and
|
other types. */
|
other types. */
|
|
|
#include <stdarg.h>
|
#include <stdarg.h>
|
|
|
extern void abort (void);
|
extern void abort (void);
|
|
|
/* Supposing the list of varying number of arguments is:
|
/* Supposing the list of varying number of arguments is:
|
unsigned int, _Decimal128, double, _Decimal32, _Decimal64. */
|
unsigned int, _Decimal128, double, _Decimal32, _Decimal64. */
|
|
|
static _Decimal32
|
static _Decimal32
|
vararg_d32 (unsigned arg, ...)
|
vararg_d32 (unsigned arg, ...)
|
{
|
{
|
va_list ap;
|
va_list ap;
|
_Decimal32 result;
|
_Decimal32 result;
|
|
|
va_start (ap, arg);
|
va_start (ap, arg);
|
|
|
va_arg (ap, unsigned int);
|
va_arg (ap, unsigned int);
|
va_arg (ap, _Decimal128);
|
va_arg (ap, _Decimal128);
|
va_arg (ap, double);
|
va_arg (ap, double);
|
result = va_arg (ap, _Decimal32);
|
result = va_arg (ap, _Decimal32);
|
|
|
va_end (ap);
|
va_end (ap);
|
return result;
|
return result;
|
}
|
}
|
|
|
static _Decimal32
|
static _Decimal32
|
vararg_d64 (unsigned arg, ...)
|
vararg_d64 (unsigned arg, ...)
|
{
|
{
|
va_list ap;
|
va_list ap;
|
_Decimal64 result;
|
_Decimal64 result;
|
|
|
va_start (ap, arg);
|
va_start (ap, arg);
|
|
|
va_arg (ap, unsigned int);
|
va_arg (ap, unsigned int);
|
va_arg (ap, _Decimal128);
|
va_arg (ap, _Decimal128);
|
va_arg (ap, double);
|
va_arg (ap, double);
|
va_arg (ap, _Decimal32);
|
va_arg (ap, _Decimal32);
|
result = va_arg (ap, _Decimal64);
|
result = va_arg (ap, _Decimal64);
|
|
|
va_end (ap);
|
va_end (ap);
|
return result;
|
return result;
|
}
|
}
|
|
|
static _Decimal128
|
static _Decimal128
|
vararg_d128 (unsigned arg, ...)
|
vararg_d128 (unsigned arg, ...)
|
{
|
{
|
va_list ap;
|
va_list ap;
|
_Decimal128 result;
|
_Decimal128 result;
|
|
|
va_start (ap, arg);
|
va_start (ap, arg);
|
|
|
va_arg (ap, unsigned int);
|
va_arg (ap, unsigned int);
|
result = va_arg (ap, _Decimal128);
|
result = va_arg (ap, _Decimal128);
|
|
|
va_end (ap);
|
va_end (ap);
|
return result;
|
return result;
|
}
|
}
|
|
|
static unsigned int
|
static unsigned int
|
vararg_int (unsigned arg, ...)
|
vararg_int (unsigned arg, ...)
|
{
|
{
|
va_list ap;
|
va_list ap;
|
unsigned int result;
|
unsigned int result;
|
|
|
va_start (ap, arg);
|
va_start (ap, arg);
|
|
|
result = va_arg (ap, unsigned int);
|
result = va_arg (ap, unsigned int);
|
|
|
va_end (ap);
|
va_end (ap);
|
return result;
|
return result;
|
}
|
}
|
|
|
static double
|
static double
|
vararg_double (unsigned arg, ...)
|
vararg_double (unsigned arg, ...)
|
{
|
{
|
va_list ap;
|
va_list ap;
|
float result;
|
float result;
|
|
|
va_start (ap, arg);
|
va_start (ap, arg);
|
|
|
va_arg (ap, unsigned int);
|
va_arg (ap, unsigned int);
|
va_arg (ap, _Decimal128);
|
va_arg (ap, _Decimal128);
|
result = va_arg (ap, double);
|
result = va_arg (ap, double);
|
|
|
va_end (ap);
|
va_end (ap);
|
return result;
|
return result;
|
}
|
}
|
|
|
|
|
int
|
int
|
main ()
|
main ()
|
{
|
{
|
if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) abort ();
|
if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) abort ();
|
if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) abort ();
|
if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) abort ();
|
if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) abort ();
|
if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) abort ();
|
if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) abort ();
|
if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) abort ();
|
if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) abort ();
|
if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) abort ();
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|