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.dg/] [fixed-point/] [func-vararg.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-std=gnu99" } */
3
 
4
/* C99 6.5.2.2 Function calls.
5
   Test passing varargs of fixed-point types.
6
   Based on the test from ../dfp/.  */
7
 
8
#include <stdarg.h>
9
 
10
extern void abort (void);
11
 
12
#define FUNC(TYPE, NAME) \
13
static TYPE \
14
vararg_ ## NAME (unsigned arg, ...) \
15
{ \
16
  int i; \
17
  va_list ap; \
18
  TYPE result; \
19
  va_start (ap, arg); \
20
  for (i = 0; i <= arg; i++) \
21
    result = va_arg (ap, TYPE); \
22
  va_end (ap); \
23
  return result; \
24
}
25
 
26
FUNC (short _Fract, sf)
27
FUNC (_Fract, f)
28
FUNC (long _Fract, lf)
29
FUNC (long long _Fract, llf)
30
FUNC (unsigned short _Fract, usf)
31
FUNC (unsigned _Fract, uf)
32
FUNC (unsigned long _Fract, ulf)
33
FUNC (unsigned long long _Fract, ullf)
34
FUNC (_Sat short _Fract, Ssf)
35
FUNC (_Sat _Fract, Sf)
36
FUNC (_Sat long _Fract, Slf)
37
FUNC (_Sat long long _Fract, Sllf)
38
FUNC (_Sat unsigned short _Fract, Susf)
39
FUNC (_Sat unsigned _Fract, Suf)
40
FUNC (_Sat unsigned long _Fract, Sulf)
41
FUNC (_Sat unsigned long long _Fract, Sullf)
42
FUNC (short _Accum, sa)
43
FUNC (_Accum, a)
44
FUNC (long _Accum, la)
45
FUNC (long long _Accum, lla)
46
FUNC (unsigned short _Accum, usa)
47
FUNC (unsigned _Accum, ua)
48
FUNC (unsigned long _Accum, ula)
49
FUNC (unsigned long long _Accum, ulla)
50
FUNC (_Sat short _Accum, Ssa)
51
FUNC (_Sat _Accum, Sa)
52
FUNC (_Sat long _Accum, Sla)
53
FUNC (_Sat long long _Accum, Slla)
54
FUNC (_Sat unsigned short _Accum, Susa)
55
FUNC (_Sat unsigned _Accum, Sua)
56
FUNC (_Sat unsigned long _Accum, Sula)
57
FUNC (_Sat unsigned long long _Accum, Sulla)
58
 
59
int main()
60
{
61
#define TEST(NAME,PF) \
62
  if (vararg_ ## NAME (0, 0.0 ## PF, 0.1 ## PF, 0.2 ## PF, 0.3 ## PF, \
63
                       0.4 ## PF, 0.5 ## PF) != 0.0 ## PF) \
64
    abort (); \
65
  if (vararg_ ## NAME (1, 0.0 ## PF, 0.1 ## PF, 0.2 ## PF, 0.3 ## PF, \
66
                       0.4 ## PF, 0.5 ## PF) != 0.1 ## PF) \
67
    abort (); \
68
  if (vararg_ ## NAME (2, 0.0 ## PF, 0.1 ## PF, 0.2 ## PF, 0.3 ## PF, \
69
                       0.4 ## PF, 0.5 ## PF) != 0.2 ## PF) \
70
    abort (); \
71
  if (vararg_ ## NAME (3, 0.0 ## PF, 0.1 ## PF, 0.2 ## PF, 0.3 ## PF, \
72
                       0.4 ## PF, 0.5 ## PF) != 0.3 ## PF) \
73
    abort (); \
74
  if (vararg_ ## NAME (4, 0.0 ## PF, 0.1 ## PF, 0.2 ## PF, 0.3 ## PF, \
75
                       0.4 ## PF, 0.5 ## PF) != 0.4 ## PF) \
76
    abort (); \
77
  if (vararg_ ## NAME (5, 0.0 ## PF, 0.1 ## PF, 0.2 ## PF, 0.3 ## PF, \
78
                       0.4 ## PF, 0.5 ## PF) != 0.5 ## PF) \
79
    abort ();
80
 
81
  TEST(sf, hr)
82
  TEST(f, r)
83
  TEST(lf, lr)
84
  TEST(llf, llr)
85
  TEST(usf, uhr)
86
  TEST(uf, ur)
87
  TEST(ulf, ulr)
88
  TEST(ullf, ullr)
89
  TEST(Ssf, hr)
90
  TEST(Sf, r)
91
  TEST(Slf, lr)
92
  TEST(Sllf, llr)
93
  TEST(Susf, uhr)
94
  TEST(Suf, ur)
95
  TEST(Sulf, ulr)
96
  TEST(Sullf, ullr)
97
  TEST(sa, hk)
98
  TEST(a, k)
99
  TEST(la, lk)
100
  TEST(lla, llk)
101
  TEST(usa, uhk)
102
  TEST(ua, uk)
103
  TEST(ula, ulk)
104
  TEST(ulla, ullk)
105
  TEST(Ssa, hk)
106
  TEST(Sa, k)
107
  TEST(Sla, lk)
108
  TEST(Slla, llk)
109
  TEST(Susa, uhk)
110
  TEST(Sua, uk)
111
  TEST(Sula, ulk)
112
  TEST(Sulla, ullk)
113
 
114
  return 0;
115
}

powered by: WebSVN 2.1.0

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