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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [fixed-point/] [unary.c] - Blame information for rev 826

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.3 Unary operators.
5
 
6
   Check unary operators ++ -- + - !.  */
7
 
8
extern void abort (void);
9
 
10
#define INCDEC(TYPE,POSTFIX) \
11
  { TYPE a = 0.0 ## POSTFIX; \
12
    if (a++ != 0.0 ## POSTFIX) \
13
      abort(); \
14
    if (a != 1.0 ## POSTFIX) \
15
      abort(); \
16
    if (a-- != 1.0 ## POSTFIX) \
17
      abort(); \
18
    if (a != 0.0 ## POSTFIX) \
19
      abort(); \
20
    if (++a != 1.0 ## POSTFIX) \
21
      abort(); \
22
    if (a != 1.0 ## POSTFIX) \
23
      abort(); \
24
    if (--a != 0.0 ## POSTFIX) \
25
      abort(); \
26
    if (a != 0.0 ## POSTFIX) \
27
      abort(); \
28
  }
29
 
30
#define FRACT_INCDEC(TYPE,POSTFIX) \
31
  { TYPE a = -0.5 ## POSTFIX; \
32
    if (a++ != -0.5 ## POSTFIX) \
33
      abort(); \
34
    if (a != 0.5 ## POSTFIX) \
35
      abort(); \
36
    if (a-- != 0.5 ## POSTFIX) \
37
      abort(); \
38
    if (a != -0.5 ## POSTFIX) \
39
      abort(); \
40
    if (++a != 0.5 ## POSTFIX) \
41
      abort(); \
42
    if (a != 0.5 ## POSTFIX) \
43
      abort(); \
44
    if (--a != -0.5 ## POSTFIX) \
45
      abort(); \
46
    if (a != -0.5 ## POSTFIX) \
47
      abort(); \
48
  }
49
 
50
#define FRACT_SAT_INCDEC(TYPE,POSTFIX) \
51
  { TYPE a = 0.9 ## POSTFIX; \
52
    if (++a != 1.0 ## POSTFIX) \
53
      abort(); \
54
    a = -0.1 ## POSTFIX; \
55
    if (--a != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
56
      abort(); \
57
  }
58
 
59
#define FRACT_SAT_UNS_INCDEC(TYPE,POSTFIX) \
60
  { TYPE a = 0.9 ## POSTFIX; \
61
    if (++a != 1.0 ## POSTFIX) \
62
      abort(); \
63
    a = 0.1 ## POSTFIX; \
64
    if (--a != 0.0 ## POSTFIX) \
65
      abort(); \
66
  }
67
 
68
#define PLUS(TYPE,POSTFIX) \
69
  { TYPE a = 0.1 ## POSTFIX; \
70
    if (+a != 0.1 ## POSTFIX) \
71
      abort(); \
72
  }
73
 
74
#define NEG(TYPE,POSTFIX) \
75
  { TYPE a = -0.1 ## POSTFIX; \
76
    if (-a != 0.1 ## POSTFIX) \
77
      abort(); \
78
  }
79
 
80
#define FRACT_SAT_NEG(TYPE,POSTFIX) \
81
  { TYPE a = -0.5 ## POSTFIX - 0.5 ## POSTFIX; \
82
    if (-a != 1.0 ## POSTFIX) \
83
      abort(); \
84
  }
85
 
86
#define UNS_NEG(TYPE,POSTFIX) \
87
  { TYPE a = 0.0 ## POSTFIX; \
88
    if (-a != 0.0 ## POSTFIX) \
89
      abort(); \
90
  }
91
 
92
#define FRACT_SAT_UNS_NEG(TYPE,POSTFIX) \
93
  { TYPE a = 0.5 ## POSTFIX; \
94
    if (-a != 0.0 ## POSTFIX) \
95
      abort(); \
96
  }
97
 
98
#define LOGNEG(TYPE,POSTFIX) \
99
  { TYPE a = 0.0 ## POSTFIX; \
100
    TYPE b = 0.1 ## POSTFIX; \
101
    if (!a != 1) \
102
      abort(); \
103
    if (!b != 0) \
104
      abort(); \
105
  }
106
 
107
int main ()
108
{
109
  FRACT_INCDEC(short _Fract, hr);
110
  FRACT_INCDEC(_Fract, r);
111
  FRACT_INCDEC(long _Fract, lr);
112
  FRACT_INCDEC(long long _Fract, llr);
113
  FRACT_INCDEC(_Sat short _Fract, hr);
114
  FRACT_INCDEC(_Sat _Fract, r);
115
  FRACT_INCDEC(_Sat long _Fract, lr);
116
  FRACT_INCDEC(_Sat long long _Fract, llr);
117
 
118
  INCDEC(short _Accum, hk);
119
  INCDEC(_Accum, k);
120
  INCDEC(long _Accum, lk);
121
  INCDEC(long long _Accum, llk);
122
  INCDEC(unsigned short _Accum, uhk);
123
  INCDEC(unsigned _Accum, uk);
124
  INCDEC(unsigned long _Accum, ulk);
125
  INCDEC(unsigned long long _Accum, ullk);
126
  INCDEC(_Sat short _Accum, hk);
127
  INCDEC(_Sat _Accum, k);
128
  INCDEC(_Sat long _Accum, lk);
129
  INCDEC(_Sat long long _Accum, llk);
130
  INCDEC(_Sat unsigned short _Accum, uhk);
131
  INCDEC(_Sat unsigned _Accum, uk);
132
  INCDEC(_Sat unsigned long _Accum, ulk);
133
  INCDEC(_Sat unsigned long long _Accum, ullk);
134
 
135
  FRACT_SAT_INCDEC(_Sat short _Fract, hr);
136
  FRACT_SAT_INCDEC(_Sat _Fract, r);
137
  FRACT_SAT_INCDEC(_Sat long _Fract, lr);
138
  FRACT_SAT_INCDEC(_Sat long long _Fract, llr);
139
 
140
  FRACT_SAT_UNS_INCDEC(_Sat unsigned short _Fract, uhr);
141
  FRACT_SAT_UNS_INCDEC(_Sat unsigned _Fract, ur);
142
  FRACT_SAT_UNS_INCDEC(_Sat unsigned long _Fract, ulr);
143
  FRACT_SAT_UNS_INCDEC(_Sat unsigned long long _Fract, ullr);
144
 
145
  PLUS(short _Fract, hr);
146
  PLUS(_Fract, r);
147
  PLUS(long _Fract, lr);
148
  PLUS(long long _Fract, llr);
149
  PLUS(unsigned short _Fract, uhr);
150
  PLUS(unsigned _Fract, ur);
151
  PLUS(unsigned long _Fract, ulr);
152
  PLUS(unsigned long long _Fract, ullr);
153
  PLUS(_Sat short _Fract, hr);
154
  PLUS(_Sat _Fract, r);
155
  PLUS(_Sat long _Fract, lr);
156
  PLUS(_Sat long long _Fract, llr);
157
  PLUS(_Sat unsigned short _Fract, uhr);
158
  PLUS(_Sat unsigned _Fract, ur);
159
  PLUS(_Sat unsigned long _Fract, ulr);
160
  PLUS(_Sat unsigned long long _Fract, ullr);
161
  PLUS(short _Accum, hk);
162
  PLUS(_Accum, k);
163
  PLUS(long _Accum, lk);
164
  PLUS(long long _Accum, llk);
165
  PLUS(unsigned short _Accum, uhk);
166
  PLUS(unsigned _Accum, uk);
167
  PLUS(unsigned long _Accum, ulk);
168
  PLUS(unsigned long long _Accum, ullk);
169
  PLUS(_Sat short _Accum, hk);
170
  PLUS(_Sat _Accum, k);
171
  PLUS(_Sat long _Accum, lk);
172
  PLUS(_Sat long long _Accum, llk);
173
  PLUS(_Sat unsigned short _Accum, uhk);
174
  PLUS(_Sat unsigned _Accum, uk);
175
  PLUS(_Sat unsigned long _Accum, ulk);
176
  PLUS(_Sat unsigned long long _Accum, ullk);
177
 
178
  NEG(short _Fract, hr);
179
  NEG(_Fract, r);
180
  NEG(long _Fract, lr);
181
  NEG(long long _Fract, llr);
182
  NEG(_Sat short _Fract, hr);
183
  NEG(_Sat _Fract, r);
184
  NEG(_Sat long _Fract, lr);
185
  NEG(_Sat long long _Fract, llr);
186
  NEG(short _Accum, hk);
187
  NEG(_Accum, k);
188
  NEG(long _Accum, lk);
189
  NEG(long long _Accum, llk);
190
  NEG(_Sat short _Accum, hk);
191
  NEG(_Sat _Accum, k);
192
  NEG(_Sat long _Accum, lk);
193
  NEG(_Sat long long _Accum, llk);
194
 
195
  FRACT_SAT_NEG(_Sat short _Fract, hr);
196
  FRACT_SAT_NEG(_Sat _Fract, r);
197
  FRACT_SAT_NEG(_Sat long _Fract, lr);
198
  FRACT_SAT_NEG(_Sat long long _Fract, llr);
199
 
200
  UNS_NEG(short _Fract, hr);
201
  UNS_NEG(_Fract, r);
202
  UNS_NEG(long _Fract, lr);
203
  UNS_NEG(long long _Fract, llr);
204
  UNS_NEG(_Sat short _Fract, hr);
205
  UNS_NEG(_Sat _Fract, r);
206
  UNS_NEG(_Sat long _Fract, lr);
207
  UNS_NEG(_Sat long long _Fract, llr);
208
  UNS_NEG(short _Accum, hk);
209
  UNS_NEG(_Accum, k);
210
  UNS_NEG(long _Accum, lk);
211
  UNS_NEG(long long _Accum, llk);
212
  UNS_NEG(_Sat short _Accum, hk);
213
  UNS_NEG(_Sat _Accum, k);
214
  UNS_NEG(_Sat long _Accum, lk);
215
  UNS_NEG(_Sat long long _Accum, llk);
216
 
217
  FRACT_SAT_UNS_NEG(_Sat unsigned short _Fract, uhr);
218
  FRACT_SAT_UNS_NEG(_Sat unsigned _Fract, ur);
219
  FRACT_SAT_UNS_NEG(_Sat unsigned long _Fract, ulr);
220
  FRACT_SAT_UNS_NEG(_Sat unsigned long long _Fract, ullr);
221
 
222
  LOGNEG(short _Fract, hr);
223
  LOGNEG(_Fract, r);
224
  LOGNEG(long _Fract, lr);
225
  LOGNEG(long long _Fract, llr);
226
  LOGNEG(unsigned short _Fract, uhr);
227
  LOGNEG(unsigned _Fract, ur);
228
  LOGNEG(unsigned long _Fract, ulr);
229
  LOGNEG(unsigned long long _Fract, ullr);
230
  LOGNEG(_Sat short _Fract, hr);
231
  LOGNEG(_Sat _Fract, r);
232
  LOGNEG(_Sat long _Fract, lr);
233
  LOGNEG(_Sat long long _Fract, llr);
234
  LOGNEG(_Sat unsigned short _Fract, uhr);
235
  LOGNEG(_Sat unsigned _Fract, ur);
236
  LOGNEG(_Sat unsigned long _Fract, ulr);
237
  LOGNEG(_Sat unsigned long long _Fract, ullr);
238
  LOGNEG(short _Accum, hk);
239
  LOGNEG(_Accum, k);
240
  LOGNEG(long _Accum, lk);
241
  LOGNEG(long long _Accum, llk);
242
  LOGNEG(unsigned short _Accum, uhk);
243
  LOGNEG(unsigned _Accum, uk);
244
  LOGNEG(unsigned long _Accum, ulk);
245
  LOGNEG(unsigned long long _Accum, ullk);
246
  LOGNEG(_Sat short _Accum, hk);
247
  LOGNEG(_Sat _Accum, k);
248
  LOGNEG(_Sat long _Accum, lk);
249
  LOGNEG(_Sat long long _Accum, llk);
250
  LOGNEG(_Sat unsigned short _Accum, uhk);
251
  LOGNEG(_Sat unsigned _Accum, uk);
252
  LOGNEG(_Sat unsigned long _Accum, ulk);
253
  LOGNEG(_Sat unsigned long long _Accum, ullk);
254
 
255
  return 0;
256
}

powered by: WebSVN 2.1.0

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