summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vmx/varargs-1.c
blob: 596137464835fbeafcf7c22fc202a206e1f868d9 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <altivec.h>
#include <stdarg.h>
#include <stdio.h>

typedef vector unsigned int T;

extern void f1(int, ...);
extern void f2(int, T, ...);
extern void f3(int, T, T, ...);
extern void f4(int, T, T, T);

void printx(T a)
{
  union {
    T v;
    unsigned int a[4];
  } u;
  u.v = a;
  printf("%d, %d, %d, %d\n", u.a[0], u.a[1], u.a[2], u.a[3]);
}

void f1(int a, ...)
{
  va_list ap;
  va_start (ap, a);
  while (a-- > 0)
    printx(va_arg(ap, T));
  va_end (ap);
}

void f2(int a, T b, ...)
{
  va_list ap;
  printx(b);
  a--;
  va_start (ap, b);
  while (a-- > 0)
    printx(va_arg(ap, T));
  va_end (ap);
}

void f3(int a, T b, T c, ...)
{
  va_list ap;
  printx(b);
  a--;
  printx(c);
  a--;
  va_start (ap, c);
  while (a-- > 0)
    printx(va_arg(ap, T));
  va_end (ap);
}

void f4(int a, T b, T c,
	T d)
{
  printx(b);
  a--;
  printx(c);
  a--;
  printx(d);
  a--;
}

int main()
{
  f4 (3,
      ((T){1,1,1,1}),
      ((T){2,2,2,2}), 
      ((T){3,3,3,3}));
  f3 (3,
      ((T){4,4,4,4}),
      ((T){5,5,5,5}), 
      ((T){6,6,6,6}));
  f2 (3,
      ((T){7,7,7,7}),
      ((T){8,8,8,8}), 
      ((T){9,9,9,9}));
  f1 (3,
      ((T){10,10,10,10}),
      ((T){11,11,11,11}), 
      ((T){12,12,12,12}));
  return 0;
}

/* { dg-output "1, 1, 1, 1(\n|\r\n|\r)" }
   { dg-output "2, 2, 2, 2(\n|\r\n|\r)" }
   { dg-output "3, 3, 3, 3(\n|\r\n|\r)" }
   { dg-output "4, 4, 4, 4(\n|\r\n|\r)" }
   { dg-output "5, 5, 5, 5(\n|\r\n|\r)" }
   { dg-output "6, 6, 6, 6(\n|\r\n|\r)" }
   { dg-output "7, 7, 7, 7(\n|\r\n|\r)" }
   { dg-output "8, 8, 8, 8(\n|\r\n|\r)" }
   { dg-output "9, 9, 9, 9(\n|\r\n|\r)" }
   { dg-output "10, 10, 10, 10(\n|\r\n|\r)" }
   { dg-output "11, 11, 11, 11(\n|\r\n|\r)" }
   { dg-output "12, 12, 12, 12(\n|\r\n|\r)" }
 */