PR c/64856
[official-gcc.git] / gcc / testsuite / gcc.dg / c99-math.h
blob81f2e6ddb433110a60af7dc21051546938ea5ab8
1 #include <math.h>
2 #include <fenv.h>
4 extern void abort(void);
6 #define C99_MATH_TESTS(nan, inf, huge, norm1, norm2, norm3, sub, zero, neg) \
7 { \
8 if (feclearexcept (FE_ALL_EXCEPT) != 0) \
9 abort(); \
12 if (fpclassify (nan) != FP_NAN) \
13 abort (); \
15 if (fpclassify (inf) != FP_INFINITE) \
16 abort (); \
18 if (fpclassify (huge) != FP_INFINITE) \
19 abort (); \
21 if (fpclassify (norm1) != FP_NORMAL) \
22 abort (); \
24 if (fpclassify (norm2) != FP_NORMAL) \
25 abort (); \
27 if (fpclassify (norm3) != FP_NORMAL) \
28 abort (); \
30 if (fpclassify (sub) != FP_SUBNORMAL) \
31 abort (); \
33 if (fpclassify (zero) != FP_ZERO) \
34 abort (); \
37 if (!isnan (nan)) \
38 abort (); \
40 if (isnan (inf)) \
41 abort (); \
43 if (isnan (huge)) \
44 abort (); \
46 if (isnan (norm1)) \
47 abort (); \
49 if (isnan (norm2)) \
50 abort (); \
52 if (isnan (norm3)) \
53 abort (); \
55 if (isnan (sub)) \
56 abort (); \
58 if (isnan (zero)) \
59 abort (); \
62 if (isinf (nan)) \
63 abort (); \
65 if (!isinf (inf)) \
66 abort (); \
68 if (!isinf (huge)) \
69 abort (); \
71 if (isinf (norm1)) \
72 abort (); \
74 if (isinf (norm2)) \
75 abort (); \
77 if (isinf (norm3)) \
78 abort (); \
80 if (isinf (sub)) \
81 abort (); \
83 if (isinf (zero)) \
84 abort (); \
87 if (isfinite (nan)) \
88 abort (); \
90 if (isfinite (inf)) \
91 abort (); \
93 if (isfinite (huge)) \
94 abort (); \
96 if (!isfinite (norm1)) \
97 abort (); \
99 if (!isfinite (norm2)) \
100 abort (); \
102 if (!isfinite (norm3)) \
103 abort (); \
105 if (!isfinite (sub)) \
106 abort (); \
108 if (!isfinite (zero)) \
109 abort (); \
112 if (isnormal (nan)) \
113 abort (); \
115 if (isnormal (inf)) \
116 abort (); \
118 if (isnormal (huge)) \
119 abort (); \
121 if (!isnormal (norm1)) \
122 abort (); \
124 if (!isnormal (norm2)) \
125 abort (); \
127 if (!isnormal (norm3)) \
128 abort (); \
130 if (isnormal (sub)) \
131 abort (); \
133 if (isnormal (zero)) \
134 abort (); \
137 if (!!signbit (nan) != neg) \
138 abort (); \
140 if (!!signbit (inf) != neg) \
141 abort (); \
143 if (!!signbit (huge) != neg) \
144 abort (); \
146 if (!!signbit (norm1) != neg) \
147 abort (); \
149 if (!!signbit (norm2) != neg) \
150 abort (); \
152 if (!!signbit (norm3) != neg) \
153 abort (); \
155 if (!!signbit (sub) != neg) \
156 abort (); \
158 if (!!signbit (zero) != neg) \
159 abort (); \
162 if (neg) \
164 if (!isless ((inf), (norm1))) \
165 abort (); \
167 if (!isless ((inf), (norm2))) \
168 abort (); \
170 if (!isless ((inf), (norm3))) \
171 abort (); \
173 if (!islessequal ((inf), (huge))) \
174 abort (); \
176 if (!isgreater ((norm1), (inf))) \
177 abort (); \
179 if (!isgreater ((norm2), (inf))) \
180 abort (); \
182 if (!isgreater ((norm3), (inf))) \
183 abort (); \
185 if (!isgreaterequal ((huge), (inf))) \
186 abort (); \
188 else \
190 if (!isgreater ((inf), (norm1))) \
191 abort (); \
193 if (!isgreater ((inf), (norm2))) \
194 abort (); \
196 if (!isgreater ((inf), (norm3))) \
197 abort (); \
199 if (!isgreaterequal ((inf), (huge))) \
200 abort (); \
202 if (!isless ((norm1), (inf))) \
203 abort (); \
205 if (!isless ((norm2), (inf))) \
206 abort (); \
208 if (!isless ((norm3), (inf))) \
209 abort (); \
211 if (!islessequal ((huge), (inf))) \
212 abort (); \
215 if (!islessgreater ((inf), (norm1))) \
216 abort (); \
218 if (!islessgreater ((inf), (norm2))) \
219 abort (); \
221 if (!islessgreater ((inf), (norm3))) \
222 abort (); \
224 if (!isunordered ((nan), (norm1))) \
225 abort (); \
227 if (!isunordered ((nan), (norm2))) \
228 abort (); \
230 if (!isunordered ((nan), (norm3))) \
231 abort (); \
234 if (fetestexcept (FE_ALL_EXCEPT) != 0) \
235 abort(); \