view gcc/testsuite/g++.dg/template/stdarg1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR c++/47022
// { dg-do compile }
// Suppress a warning that is irrelevant to the purpose of this test.
// { dg-options "-Wno-abi" { target arm_eabi } }

#include <cstdarg>

template <typename T>
void
f1 (T *p, va_list ap)
{
  *p = va_arg (ap, long double);
  *p += va_arg (ap, double);
}

template <typename T>
void
f2 (T *p, va_list ap)
{
  *p = __real__ va_arg (ap, _Complex int);
  *p += __imag__ va_arg (ap, _Complex double);
  *p += __imag__ va_arg (ap, _Complex long double);
}

template <typename T>
void
f3 (T *p, va_list ap)
{
  *p = va_arg (ap, T);
}

void
foo (int x, va_list ap)
{
  if (x == 0)
    {
      long double ld;
      f1 (&ld, ap);
    }
  else if (x == 1)
    {
      int i;
      f2 (&i, ap);
    }
  else if (x == 2)
    {
      long double ld;
      f3 (&ld, ap);
    }
  else if (x == 3)
    {
      _Complex double cd;
      f3 (&cd, ap);
    }
}