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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.2.2 Function calls.
Test structure passing and return values involving fixed-point types.
Based on the test from ../dfp/. */
extern void abort (void);
struct example
{
short _Fract sf;
char dummy1;
_Fract f;
char dummy2;
long _Fract lf;
char dummy3;
long long _Fract llf;
char dummy4;
unsigned short _Fract usf;
char dummy5;
unsigned _Fract uf;
char dummy6;
unsigned long _Fract ulf;
char dummy7;
unsigned long long _Fract ullf;
char dummy8;
_Sat short _Fract Ssf;
char dummy9;
_Sat _Fract Sf;
char dummy10;
_Sat long _Fract Slf;
char dummy11;
_Sat long long _Fract Sllf;
char dummy12;
_Sat unsigned short _Fract Susf;
char dummy13;
_Sat unsigned _Fract Suf;
char dummy14;
_Sat unsigned long _Fract Sulf;
char dummy15;
_Sat unsigned long long _Fract Sullf;
char dummy16;
short _Accum sa;
char dummya1;
_Accum a;
char dummya2;
long _Accum la;
char dummya3;
long long _Accum lla;
char dummya4;
unsigned short _Accum usa;
char dummya5;
unsigned _Accum ua;
char dummya6;
unsigned long _Accum ula;
char dummya7;
unsigned long long _Accum ulla;
char dummya8;
_Sat short _Accum Ssa;
char dummya9;
_Sat _Accum Sa;
char dummya10;
_Sat long _Accum Sla;
char dummya11;
_Sat long long _Accum Slla;
char dummya12;
_Sat unsigned short _Accum Susa;
char dummya13;
_Sat unsigned _Accum Sua;
char dummya14;
_Sat unsigned long _Accum Sula;
char dummya15;
_Sat unsigned long long _Accum Sulla;
char dummya16;
} nums = { 0.1hr, 'a',
0.2r, 'b',
0.3lr, 'c',
0.4llr, 'd',
0.5uhr, 'e',
0.6ur, 'f',
0.7ulr, 'g',
0.8ullr, 'h',
0.11r, 'i',
0.22r, 'j',
0.33lr, 'k',
0.44llr, 'l',
0.55uhr, 'm',
0.66ur, 'n',
0.77ulr, 'o',
0.88ullr, 'p',
0.1hk, 'q',
0.2k, 'r',
0.3lk, 's',
0.4llk, 't',
0.5uhk, 'u',
0.6uk, 'v',
0.7ulk, 'w',
0.8ullk, 'x',
0.11k, 'y',
0.22k, 'z',
0.33lk, '0',
0.44llk, '1',
0.55uhk, '2',
0.66uk, '3',
0.77ulk, '4',
0.88ullk, '5'
};
/* A handful of functions that return the Nth argument of
an incoming array. */
#define FUNC(TYPE,NAME) \
TYPE NAME ## _func (struct example s) \
{ return s. NAME; }
FUNC (short _Fract, sf)
FUNC (_Fract, f)
FUNC (long _Fract, lf)
FUNC (long long _Fract, llf)
FUNC (unsigned short _Fract, usf)
FUNC (unsigned _Fract, uf)
FUNC (unsigned long _Fract, ulf)
FUNC (unsigned long long _Fract, ullf)
FUNC (_Sat short _Fract, Ssf)
FUNC (_Sat _Fract, Sf)
FUNC (_Sat long _Fract, Slf)
FUNC (_Sat long long _Fract, Sllf)
FUNC (_Sat unsigned short _Fract, Susf)
FUNC (_Sat unsigned _Fract, Suf)
FUNC (_Sat unsigned long _Fract, Sulf)
FUNC (_Sat unsigned long long _Fract, Sullf)
FUNC (short _Accum, sa)
FUNC (_Accum, a)
FUNC (long _Accum, la)
FUNC (long long _Accum, lla)
FUNC (unsigned short _Accum, usa)
FUNC (unsigned _Accum, ua)
FUNC (unsigned long _Accum, ula)
FUNC (unsigned long long _Accum, ulla)
FUNC (_Sat short _Accum, Ssa)
FUNC (_Sat _Accum, Sa)
FUNC (_Sat long _Accum, Sla)
FUNC (_Sat long long _Accum, Slla)
FUNC (_Sat unsigned short _Accum, Susa)
FUNC (_Sat unsigned _Accum, Sua)
FUNC (_Sat unsigned long _Accum, Sula)
FUNC (_Sat unsigned long long _Accum, Sulla)
int main()
{
#define TEST(TYPE,NAME,VALUE) \
{ \
if (NAME ## _func (nums) != VALUE) abort (); \
}
TEST (short _Fract, sf, 0.1hr)
TEST (_Fract, f, 0.2r)
TEST (long _Fract, lf, 0.3lr)
TEST (long long _Fract, llf, 0.4llr)
TEST (unsigned short _Fract, usf, 0.5uhr)
TEST (unsigned _Fract, uf, 0.6ur)
TEST (unsigned long _Fract, ulf, 0.7ulr)
TEST (unsigned long long _Fract, ullf, 0.8ullr)
TEST (_Sat short _Fract, Ssf, 0.11hr)
TEST (_Sat _Fract, Sf, 0.22r)
TEST (_Sat long _Fract, Slf, 0.33lr)
TEST (_Sat long long _Fract, Sllf, 0.44llr)
TEST (_Sat unsigned short _Fract, Susf, 0.55uhr)
TEST (_Sat unsigned _Fract, Suf, 0.66ur)
TEST (_Sat unsigned long _Fract, Sulf, 0.77ulr)
TEST (_Sat unsigned long long _Fract, Sullf, 0.88ullr)
TEST (short _Accum, sa, 0.1hk)
TEST (_Accum, a, 0.2k)
TEST (long _Accum, la, 0.3lk)
TEST (long long _Accum, lla, 0.4llk)
TEST (unsigned short _Accum, usa, 0.5uhk)
TEST (unsigned _Accum, ua, 0.6uk)
TEST (unsigned long _Accum, ula, 0.7ulk)
TEST (unsigned long long _Accum, ulla, 0.8ullk)
TEST (_Sat short _Accum, Ssa, 0.11hk)
TEST (_Sat _Accum, Sa, 0.22k)
TEST (_Sat long _Accum, Sla, 0.33lk)
TEST (_Sat long long _Accum, Slla, 0.44llk)
TEST (_Sat unsigned short _Accum, Susa, 0.55uhk)
TEST (_Sat unsigned _Accum, Sua, 0.66uk)
TEST (_Sat unsigned long _Accum, Sula, 0.77ulk)
TEST (_Sat unsigned long long _Accum, Sulla, 0.88ullk)
return 0;
}
|