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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [stdarg-4.c] - Blame information for rev 297

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
#include <stdarg.h>
2
 
3
extern void abort (void);
4
long x, y;
5
 
6
inline void __attribute__((always_inline))
7
f1i (va_list ap)
8
{
9
  x = va_arg (ap, double);
10
  x += va_arg (ap, long);
11
  x += va_arg (ap, double);
12
}
13
 
14
void
15
f1 (int i, ...)
16
{
17
  va_list ap;
18
  va_start (ap, i);
19
  f1i (ap);
20
  va_end (ap);
21
}
22
 
23
inline void __attribute__((always_inline))
24
f2i (va_list ap)
25
{
26
  y = va_arg (ap, int);
27
  y += va_arg (ap, long);
28
  y += va_arg (ap, double);
29
  f1i (ap);
30
}
31
 
32
void
33
f2 (int i, ...)
34
{
35
  va_list ap;
36
  va_start (ap, i);
37
  f2i (ap);
38
  va_end (ap);
39
}
40
 
41
long
42
f3h (int i, long arg0, long arg1, long arg2, long arg3)
43
{
44
  return i + arg0 + arg1 + arg2 + arg3;
45
}
46
 
47
long
48
f3 (int i, ...)
49
{
50
  long t, arg0, arg1, arg2, arg3;
51
  va_list ap;
52
 
53
  va_start (ap, i);
54
  switch (i)
55
    {
56
    case 0:
57
      t = f3h (i, 0, 0, 0, 0);
58
      break;
59
    case 1:
60
      arg0 = va_arg (ap, long);
61
      t = f3h (i, arg0, 0, 0, 0);
62
      break;
63
    case 2:
64
      arg0 = va_arg (ap, long);
65
      arg1 = va_arg (ap, long);
66
      t = f3h (i, arg0, arg1, 0, 0);
67
      break;
68
    case 3:
69
      arg0 = va_arg (ap, long);
70
      arg1 = va_arg (ap, long);
71
      arg2 = va_arg (ap, long);
72
      t = f3h (i, arg0, arg1, arg2, 0);
73
      break;
74
    case 4:
75
      arg0 = va_arg (ap, long);
76
      arg1 = va_arg (ap, long);
77
      arg2 = va_arg (ap, long);
78
      arg3 = va_arg (ap, long);
79
      t = f3h (i, arg0, arg1, arg2, arg3);
80
      break;
81
    default:
82
      abort ();
83
    }
84
  va_end (ap);
85
 
86
  return t;
87
}
88
 
89
void
90
f4 (int i, ...)
91
{
92
  va_list ap;
93
 
94
  va_start (ap, i);
95
  switch (i)
96
    {
97
    case 4:
98
      y = va_arg (ap, double);
99
      break;
100
    case 5:
101
      y = va_arg (ap, double);
102
      y += va_arg (ap, double);
103
      break;
104
    default:
105
      abort ();
106
    }
107
  f1i (ap);
108
  va_end (ap);
109
}
110
 
111
int
112
main (void)
113
{
114
  f1 (3, 16.0, 128L, 32.0);
115
  if (x != 176L)
116
    abort ();
117
  f2 (6, 5, 7L, 18.0, 19.0, 17L, 64.0);
118
  if (x != 100L || y != 30L)
119
    abort ();
120
  if (f3 (0) != 0)
121
    abort ();
122
  if (f3 (1, 18L) != 19L)
123
    abort ();
124
  if (f3 (2, 18L, 100L) != 120L)
125
    abort ();
126
  if (f3 (3, 18L, 100L, 300L) != 421L)
127
    abort ();
128
  if (f3 (4, 18L, 71L, 64L, 86L) != 243L)
129
    abort ();
130
  f4 (4, 6.0, 9.0, 16L, 18.0);
131
  if (x != 43L || y != 6L)
132
    abort ();
133
  f4 (5, 7.0, 21.0, 1.0, 17L, 126.0);
134
  if (x != 144L || y != 28L)
135
    abort ();
136
  return 0;
137
}

powered by: WebSVN 2.1.0

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