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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [cpp/] [arith-1.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Preprocessor arithmetic semantic tests.  */
2
 
3
/* Copyright (C) 2002 Free Software Foundation, Inc.  */
4
/* Source: Neil Booth, 25 May 2002.  */
5
 
6
/* The file tests all aspects of preprocessor arithmetic that are
7
   independent of target precision.  */
8
 
9
/* { dg-do preprocess } */
10
/* { dg-options -fno-show-column } */
11
 
12
/* Test || operator and its short circuiting.  */
13
#if 0 || 0
14
# error         /* { dg-bogus "error" }  */
15
#endif
16
 
17
#if 5 || 0
18
#else
19
# error         /* { dg-bogus "error" }  */
20
#endif
21
 
22
#if 0 || 1
23
#else
24
# error         /* { dg-bogus "error" }  */
25
#endif
26
 
27
#if 1 || 4
28
#else
29
# error         /* { dg-bogus "error" }  */
30
#endif
31
 
32
#if 1 || (8 / 0) /* { dg-bogus "division by zero" }  */
33
#else
34
# error         /* { dg-bogus "error" }  */
35
#endif
36
 
37
#if 1 || (1 << 256) /* { dg-bogus "overflow" }  */
38
#endif
39
 
40
/* Test && operator and its short circuiting.  */
41
#if (0 && 0) || (0 && 1) || (1 && 0)
42
# error         /* { dg-bogus "error" }  */
43
#endif
44
 
45
#if 1 && 2
46
#else
47
# error         /* { dg-bogus "error" }  */
48
#endif
49
 
50
#if 0 && (8 / 0)/* { dg-bogus "division by zero" }  */
51
# error         /* { dg-bogus "error" }  */
52
#endif
53
 
54
#if 0 && (1 << 256) /* { dg-bogus "overflow" }  */
55
#endif
56
 
57
/* Test == and != operators, and their signedness.  */
58
#if 1 == 0 || 0 == 1 || 20 != 0x014 || 142 != 0216
59
# error         /* { dg-bogus "error" }  */
60
#endif
61
 
62
#if (1 == 1) - 2 > 0 || (1U != 1U) - 2 > 0
63
# error         /* { dg-bogus "error" }  */
64
#endif
65
 
66
/* Test ? : operator, its short circuiting, and its signedness.  */
67
#if (1 ? 3: 5) != 3 || (0 ? 3: 5) != 5
68
# error         /* { dg-bogus "error" }  */
69
#endif
70
 
71
#if 1 ? 0: 1 / 0 /* { dg-bogus "division by zero" }  */
72
# error         /* { dg-bogus "error" }  */
73
#endif
74
 
75
#if 0 ? 1 / 0: 0 /* { dg-bogus "division by zero" }  */
76
# error         /* { dg-bogus "error" }  */
77
#endif
78
 
79
#if 0 ? (1 << 256): 0 /* { dg-bogus "overflow" }  */
80
#endif
81
 
82
#if 1 ? 0: (1 << 256) /* { dg-bogus "overflow" }  */
83
#endif
84
 
85
/* Test unary + and its signedness.  */
86
 
87
#if 23 != +23 || 23 != + +23
88
# error         /* { dg-bogus "error" }  */
89
#endif
90
 
91
#if (+1 - 2) > 0 || (+1U - 2) < 0
92
# error         /* { dg-bogus "error" }  */
93
#endif
94
 
95
/* Test unary - and its signedness.  */
96
 
97
#if -1 + 1 != 0
98
# error         /* { dg-bogus "error" }  */
99
#endif
100
 
101
#if -1 >= 0 || -1U <= 0
102
# error         /* { dg-bogus "error" }  */
103
#endif
104
 
105
/* Test unary ! and its signedness.  */
106
#if !5 != 0 || !1 != 0 || !0 != 1
107
# error         /* { dg-bogus "error" }  */
108
#endif
109
 
110
#if !5 - 1 > 0 || !5U - 1 > 0
111
# error         /* { dg-bogus "error" }  */
112
#endif
113
 
114
/* Test unary ~ and its signedness.  */
115
#if ~0 != -1 || ~~5 != 5 || ~-2 != 1
116
# error         /* { dg-bogus "error" }  */
117
#endif
118
 
119
#if ~5 > 0 || ~5U < 0
120
# error         /* { dg-bogus "error" }  */
121
#endif
122
 
123
/* Test comparison operators and their signedness.  */
124
#if 1 >= 1 && 2 >= 1 && -1 >= -1 && -1 >= -2 && 1 >= -1 && 1 >= -2 \
125
    && !(-2 >= -1) && !(2 >= 3) && -1U >= 2 && !(-1 >= 1)
126
#else
127
# error         /* { dg-bogus "error" }  */
128
#endif
129
 
130
#if ((1 > 0) - 2) > 0 || ((1U > 0) - 2) > 0
131
# error         /* { dg-bogus "error" }  */
132
#endif
133
 
134
#if !(1 > 1) && 2 > 1 && !(-1 > -1) && -1 > -2 && 1 > -1 && 1 > -2 \
135
    && !(-2 > -1) && !(2 > 3) && -1U > 2 && !(-1 > 1)
136
#else
137
# error         /* { dg-bogus "error" }  */
138
#endif
139
 
140
#if ((1 >= 0) - 2) > 0 || ((1U >= 0) - 2) > 0
141
# error         /* { dg-bogus "error" }  */
142
#endif
143
 
144
#if 1 <= 1 && !(2 <= 1) && -1 <= -1 && !(-1 <= -2) && !(1 <= -1) && !(1 <= -2) \
145
    && -2 <= -1 && 2 <= 3 && !(-1U <= 2) && -1 <= 1
146
#else
147
# error         /* { dg-bogus "error" }  */
148
#endif
149
 
150
#if ((1 <= 0) - 2) > 0 || ((1U <= 0) - 2) > 0
151
# error         /* { dg-bogus "error" }  */
152
#endif
153
 
154
#if !(1 < 1) && !(2 < 1) && !(-1 < -1) && !(-1 < -2) && !(1 < -1) && !(1 < -2) \
155
    && -2 < -1 && 2 < 3 && !(-1U < 2) && -1 < 1
156
#else
157
# error         /* { dg-bogus "error" }  */
158
#endif
159
 
160
#if ((1 < 0) - 2) > 0 || ((1U < 0) - 2) > 0
161
# error         /* { dg-bogus "error" }  */
162
#endif
163
 
164
/* Test bitwise operators and their signedness.  */
165
#if (3 & 7) != 3 || (-1 & 34) != 34
166
# error         /* { dg-bogus "error" }  */
167
#endif
168
 
169
#if (3 & 7) - 20 > 0 || (3 & 7U) - 20 < 0
170
# error         /* { dg-bogus "error" }  */
171
#endif
172
 
173
#if (3 | 5) != 7 || (-1 | 34) != -1
174
# error         /* { dg-bogus "error" }  */
175
#endif
176
 
177
#if (3 | 7) - 20 > 0 || (3 | 7U) - 20 < 0
178
# error         /* { dg-bogus "error" }  */
179
#endif
180
 
181
#if (7 ^ 5) != 2 || (-1 ^ 34) != ~34
182
# error         /* { dg-bogus "error" }  */
183
#endif
184
 
185
#if (3 ^ 7) - 20 > 0 || (3 ^ 7U) - 20 < 0
186
# error         /* { dg-bogus "error" }  */
187
#endif
188
 
189
/* Test shifts and their signedness.  */
190
#if 3 << 2 != 12 || 3 << -2 != 0 || -1 << 1 != -2
191
# error         /* { dg-bogus "error" }  */
192
#endif
193
 
194
#if 5 >> 1 != 2 || 5 >> -2 != 20 || -5 >> 1 != -3
195
# error         /* { dg-bogus "error" }  */
196
#endif
197
 
198
#if (5 >> 2) - 2 >= 0 || (5U >> 2) - 2 <= 0
199
# error         /* { dg-bogus "error" }  */
200
#endif
201
 
202
#if (5 << 1) - 20 >= 0 || (5U << 1) - 20 <= 0
203
# error         /* { dg-bogus "error" }  */
204
#endif
205
 
206
#if 0
207
/* Test min / max and their signedness.  */
208
#if (3 >? 2) != 3 || (-3 >? -2) != -2
209
# error         /* { dg-bogus "error" }  */
210
#endif
211
 
212
#if (3 <? 2) != 2 || (-3 <? -2) != -3
213
# error         /* { dg-bogus "error" }  */
214
#endif
215
 
216
#if (3 >? 2) - 4 >= 0 || (3 >? 2U) - 4 <= 0
217
# error         /* { dg-bogus "error" }  */
218
#endif
219
 
220
#if (3 <? 2) - 4 >= 0 || (3 <? 2U) - 4 <= 0
221
# error         /* { dg-bogus "error" }  */
222
#endif
223
#endif
224
 
225
/* Test *, / and % and their signedness.  */
226
#if 3 * 2 != 6 || 3 * -2 != -6 || -2 * 3 != -6 || -2 * -3 != 6
227
# error         /* { dg-bogus "error" }  */
228
#endif
229
 
230
#if 3 * 2 - 7 >= 0 || 3 * 2U - 7 < 0
231
# error         /* { dg-bogus "error" }  */
232
#endif
233
 
234
#if 5 / 2 != 2 || -325 / 50 != -6 || 53 / -4 != -13 || -55 / -12 != 4
235
# error         /* { dg-bogus "error" }  */
236
#endif
237
 
238
#if 3 / 2 - 7 >= 0 || 3 / 2U - 7 < 0
239
# error         /* { dg-bogus "error" }  */
240
#endif
241
 
242
#if 5 % 2 != 1 || -325 % 50 != -25 || 53 % -4 != 1 || -55 % -12 != -7
243
# error         /* { dg-bogus "error" }  */
244
#endif
245
 
246
#if 3 % 2 - 7 >= 0 || 3U % 2 - 7 < 0
247
# error         /* { dg-bogus "error" }  */
248
#endif
249
 
250
/* Test , and its signedness.  */
251
#if (1, 2) != 2 || (2, 1) != 1
252
# error         /* { dg-bogus "error" }  */
253
#endif
254
 
255
#if (1, 2) - 3 >= 0 || (1, 2U) - 3 <= 0 || (1U, 2) - 3 >= 0
256
# error         /* { dg-bogus "error" }  */
257
#endif

powered by: WebSVN 2.1.0

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