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-struct.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 structure passing and return values involving fixed-point types.
6
   Based on the test from ../dfp/.  */
7
 
8
extern void abort (void);
9
 
10
struct example
11
{
12
  short _Fract sf;
13
  char dummy1;
14
  _Fract f;
15
  char dummy2;
16
  long _Fract lf;
17
  char dummy3;
18
  long long _Fract llf;
19
  char dummy4;
20
  unsigned short _Fract usf;
21
  char dummy5;
22
  unsigned _Fract uf;
23
  char dummy6;
24
  unsigned long _Fract ulf;
25
  char dummy7;
26
  unsigned long long _Fract ullf;
27
  char dummy8;
28
  _Sat short _Fract Ssf;
29
  char dummy9;
30
  _Sat _Fract Sf;
31
  char dummy10;
32
  _Sat long _Fract Slf;
33
  char dummy11;
34
  _Sat long long _Fract Sllf;
35
  char dummy12;
36
  _Sat unsigned short _Fract Susf;
37
  char dummy13;
38
  _Sat unsigned _Fract Suf;
39
  char dummy14;
40
  _Sat unsigned long _Fract Sulf;
41
  char dummy15;
42
  _Sat unsigned long long _Fract Sullf;
43
  char dummy16;
44
  short _Accum sa;
45
  char dummya1;
46
  _Accum a;
47
  char dummya2;
48
  long _Accum la;
49
  char dummya3;
50
  long long _Accum lla;
51
  char dummya4;
52
  unsigned short _Accum usa;
53
  char dummya5;
54
  unsigned _Accum ua;
55
  char dummya6;
56
  unsigned long _Accum ula;
57
  char dummya7;
58
  unsigned long long _Accum ulla;
59
  char dummya8;
60
  _Sat short _Accum Ssa;
61
  char dummya9;
62
  _Sat _Accum Sa;
63
  char dummya10;
64
  _Sat long _Accum Sla;
65
  char dummya11;
66
  _Sat long long _Accum Slla;
67
  char dummya12;
68
  _Sat unsigned short _Accum Susa;
69
  char dummya13;
70
  _Sat unsigned _Accum Sua;
71
  char dummya14;
72
  _Sat unsigned long _Accum Sula;
73
  char dummya15;
74
  _Sat unsigned long long _Accum Sulla;
75
  char dummya16;
76
} nums = { 0.1hr, 'a',
77
           0.2r, 'b',
78
           0.3lr, 'c',
79
           0.4llr, 'd',
80
           0.5uhr, 'e',
81
           0.6ur, 'f',
82
           0.7ulr, 'g',
83
           0.8ullr, 'h',
84
           0.11r, 'i',
85
           0.22r, 'j',
86
           0.33lr, 'k',
87
           0.44llr, 'l',
88
           0.55uhr, 'm',
89
           0.66ur, 'n',
90
           0.77ulr, 'o',
91
           0.88ullr, 'p',
92
           0.1hk, 'q',
93
           0.2k, 'r',
94
           0.3lk, 's',
95
           0.4llk, 't',
96
           0.5uhk, 'u',
97
           0.6uk, 'v',
98
           0.7ulk, 'w',
99
           0.8ullk, 'x',
100
           0.11k, 'y',
101
           0.22k, 'z',
102
           0.33lk, '0',
103
           0.44llk, '1',
104
           0.55uhk, '2',
105
           0.66uk, '3',
106
           0.77ulk, '4',
107
           0.88ullk, '5'
108
         };
109
 
110
/* A handful of functions that return the Nth argument of
111
   an incoming array.  */
112
 
113
#define FUNC(TYPE,NAME) \
114
TYPE NAME ## _func (struct example s) \
115
  { return s. NAME; }
116
 
117
FUNC (short _Fract, sf)
118
FUNC (_Fract, f)
119
FUNC (long _Fract, lf)
120
FUNC (long long _Fract, llf)
121
FUNC (unsigned short _Fract, usf)
122
FUNC (unsigned _Fract, uf)
123
FUNC (unsigned long _Fract, ulf)
124
FUNC (unsigned long long _Fract, ullf)
125
FUNC (_Sat short _Fract, Ssf)
126
FUNC (_Sat _Fract, Sf)
127
FUNC (_Sat long _Fract, Slf)
128
FUNC (_Sat long long _Fract, Sllf)
129
FUNC (_Sat unsigned short _Fract, Susf)
130
FUNC (_Sat unsigned _Fract, Suf)
131
FUNC (_Sat unsigned long _Fract, Sulf)
132
FUNC (_Sat unsigned long long _Fract, Sullf)
133
FUNC (short _Accum, sa)
134
FUNC (_Accum, a)
135
FUNC (long _Accum, la)
136
FUNC (long long _Accum, lla)
137
FUNC (unsigned short _Accum, usa)
138
FUNC (unsigned _Accum, ua)
139
FUNC (unsigned long _Accum, ula)
140
FUNC (unsigned long long _Accum, ulla)
141
FUNC (_Sat short _Accum, Ssa)
142
FUNC (_Sat _Accum, Sa)
143
FUNC (_Sat long _Accum, Sla)
144
FUNC (_Sat long long _Accum, Slla)
145
FUNC (_Sat unsigned short _Accum, Susa)
146
FUNC (_Sat unsigned _Accum, Sua)
147
FUNC (_Sat unsigned long _Accum, Sula)
148
FUNC (_Sat unsigned long long _Accum, Sulla)
149
 
150
int main()
151
{
152
#define TEST(TYPE,NAME,VALUE) \
153
  { \
154
    if (NAME ## _func (nums) != VALUE) abort (); \
155
  }
156
 
157
  TEST (short _Fract, sf, 0.1hr)
158
  TEST (_Fract, f, 0.2r)
159
  TEST (long _Fract, lf, 0.3lr)
160
  TEST (long long _Fract, llf, 0.4llr)
161
  TEST (unsigned short _Fract, usf, 0.5uhr)
162
  TEST (unsigned _Fract, uf, 0.6ur)
163
  TEST (unsigned long _Fract, ulf, 0.7ulr)
164
  TEST (unsigned long long _Fract, ullf, 0.8ullr)
165
  TEST (_Sat short _Fract, Ssf, 0.11hr)
166
  TEST (_Sat _Fract, Sf, 0.22r)
167
  TEST (_Sat long _Fract, Slf, 0.33lr)
168
  TEST (_Sat long long _Fract, Sllf, 0.44llr)
169
  TEST (_Sat unsigned short _Fract, Susf, 0.55uhr)
170
  TEST (_Sat unsigned _Fract, Suf, 0.66ur)
171
  TEST (_Sat unsigned long _Fract, Sulf, 0.77ulr)
172
  TEST (_Sat unsigned long long _Fract, Sullf, 0.88ullr)
173
  TEST (short _Accum, sa, 0.1hk)
174
  TEST (_Accum, a, 0.2k)
175
  TEST (long _Accum, la, 0.3lk)
176
  TEST (long long _Accum, lla, 0.4llk)
177
  TEST (unsigned short _Accum, usa, 0.5uhk)
178
  TEST (unsigned _Accum, ua, 0.6uk)
179
  TEST (unsigned long _Accum, ula, 0.7ulk)
180
  TEST (unsigned long long _Accum, ulla, 0.8ullk)
181
  TEST (_Sat short _Accum, Ssa, 0.11hk)
182
  TEST (_Sat _Accum, Sa, 0.22k)
183
  TEST (_Sat long _Accum, Sla, 0.33lk)
184
  TEST (_Sat long long _Accum, Slla, 0.44llk)
185
  TEST (_Sat unsigned short _Accum, Susa, 0.55uhk)
186
  TEST (_Sat unsigned _Accum, Sua, 0.66uk)
187
  TEST (_Sat unsigned long _Accum, Sula, 0.77ulk)
188
  TEST (_Sat unsigned long long _Accum, Sulla, 0.88ullk)
189
 
190
  return 0;
191
}

powered by: WebSVN 2.1.0

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