OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [stdarg-3.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
#include <stdarg.h>
2
 
3
extern void abort (void);
4
 
5
int foo_arg, bar_arg;
6
long x;
7
double d;
8
va_list gap;
9
struct S1 { int i; double d; int j; double e; } s1;
10
struct S2 { double d; long i; } s2;
11
int y;
12
 
13
void
14
bar (int v)
15
{
16
  bar_arg = v;
17
}
18
 
19
void
20
f1 (int i, ...)
21
{
22
  va_list ap;
23
  va_start (ap, i);
24
  while (i-- > 0)
25
    x = va_arg (ap, long);
26
  va_end (ap);
27
}
28
 
29
void
30
f2 (int i, ...)
31
{
32
  va_list ap;
33
  va_start (ap, i);
34
  while (i-- > 0)
35
    d = va_arg (ap, double);
36
  va_end (ap);
37
}
38
 
39
void
40
f3 (int i, ...)
41
{
42
  va_list ap;
43
  int j = i;
44
  while (j-- > 0)
45
    {
46
      va_start (ap, i);
47
      x = va_arg (ap, long);
48
      va_end (ap);
49
      bar (x);
50
    }
51
}
52
 
53
void
54
f4 (int i, ...)
55
{
56
  va_list ap;
57
  int j = i;
58
  while (j-- > 0)
59
    {
60
      va_start (ap, i);
61
      d = va_arg (ap, double);
62
      va_end (ap);
63
      bar (d + 4.0);
64
    }
65
}
66
 
67
void
68
f5 (int i, ...)
69
{
70
  va_list ap;
71
  va_start (ap, i);
72
  while (i-- > 0)
73
    s1 = va_arg (ap, struct S1);
74
  va_end (ap);
75
}
76
 
77
void
78
f6 (int i, ...)
79
{
80
  va_list ap;
81
  va_start (ap, i);
82
  while (i-- > 0)
83
    s2 = va_arg (ap, struct S2);
84
  va_end (ap);
85
}
86
 
87
void
88
f7 (int i, ...)
89
{
90
  va_list ap;
91
  int j = i;
92
  while (j-- > 0)
93
    {
94
      va_start (ap, i);
95
      s1 = va_arg (ap, struct S1);
96
      va_end (ap);
97
      bar (s1.i);
98
    }
99
}
100
 
101
void
102
f8 (int i, ...)
103
{
104
  va_list ap;
105
  int j = i;
106
  while (j-- > 0)
107
    {
108
      va_start (ap, i);
109
      s2 = va_arg (ap, struct S2);
110
      y = va_arg (ap, int);
111
      va_end (ap);
112
      bar (s2.i);
113
    }
114
}
115
 
116
int
117
main (void)
118
{
119
  struct S1 a1, a3;
120
  struct S2 a2, a4;
121
 
122
  f1 (7, 1L, 2L, 3L, 5L, 7L, 9L, 11L, 13L);
123
  if (x != 11L)
124
    abort ();
125
  f2 (6, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0);
126
  if (d != 32.0)
127
    abort ();
128
  f3 (2, 1L, 3L);
129
  if (bar_arg != 1L || x != 1L)
130
    abort ();
131
  f4 (2, 17.0, 19.0);
132
  if (bar_arg != 21 || d != 17.0)
133
    abort ();
134
  a1.i = 131;
135
  a1.j = 251;
136
  a1.d = 15.0;
137
  a1.e = 191.0;
138
  a3 = a1;
139
  a3.j = 254;
140
  a3.e = 178.0;
141
  f5 (2, a1, a3, a1);
142
  if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)
143
    abort ();
144
  f5 (3, a1, a3, a1);
145
  if (s1.i != 131 || s1.j != 251 || s1.d != 15.0 || s1.e != 191.0)
146
    abort ();
147
  a2.i = 138;
148
  a2.d = 16.0;
149
  a4.i = 257;
150
  a4.d = 176.0;
151
  f6 (2, a2, a4, a2);
152
  if (s2.i != 257 || s2.d != 176.0)
153
    abort ();
154
  f6 (3, a2, a4, a2);
155
  if (s2.i != 138 || s2.d != 16.0)
156
    abort ();
157
  f7 (2, a3, a1, a1);
158
  if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)
159
    abort ();
160
  if (bar_arg != 131)
161
    abort ();
162
  f8 (3, a4, a2, a2);
163
  if (s2.i != 257 || s2.d != 176.0)
164
    abort ();
165
  return 0;
166
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.