summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/stdarg1.C
blob: 94804eeed822af71fb4bb89877e83bc0765803f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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);
    }
}