|
14 | 14 | // expected-no-diagnostics
|
15 | 15 |
|
16 | 16 | /* Basic floating point conformance checks against:
|
| 17 | + - C23 Final Std. |
17 | 18 | - N1570 draft of C11 Std.
|
18 | 19 | - N1256 draft of C99 Std.
|
19 | 20 | - http://port70.net/~nsz/c/c89/c89-draft.html draft of C89/C90 Std.
|
20 | 21 | */
|
21 | 22 | /*
|
| 23 | + C23, 5.2.5.3.3p21, pp. 25 |
22 | 24 | C11, 5.2.4.2.2p11, pp. 30
|
23 | 25 | C99, 5.2.4.2.2p9, pp. 25
|
24 | 26 | C89, 2.2.4.2
|
|
225 | 227 | _Static_assert(_Generic(INFINITY, float : 1, default : 0), ""); // finite-warning {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
|
226 | 228 | _Static_assert(_Generic(NAN, float : 1, default : 0), ""); // finite-warning {{use of NaN is undefined behavior due to the currently enabled floating-point options}} \
|
227 | 229 | finite-warning {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
|
| 230 | + |
| 231 | +#ifndef FLT_NORM_MAX |
| 232 | + #error "Mandatory macro FLT_NORM_MAX is missing." |
| 233 | +#else |
| 234 | + _Static_assert(FLT_NORM_MAX >= 1.0E+37F, "Mandatory macro FLT_NORM_MAX is invalid."); |
| 235 | +#endif |
| 236 | +#ifndef DBL_NORM_MAX |
| 237 | + #error "Mandatory macro DBL_NORM_MAX is missing." |
| 238 | +#else |
| 239 | + _Static_assert(DBL_NORM_MAX >= 1.0E+37, "Mandatory macro DBL_NORM_MAX is invalid."); |
| 240 | +#endif |
| 241 | +#ifndef LDBL_NORM_MAX |
| 242 | + #error "Mandatory macro LDBL_NORM_MAX is missing." |
| 243 | +#else |
| 244 | + _Static_assert(LDBL_NORM_MAX >= 1.0E+37L, "Mandatory macro LDBL_NORM_MAX is invalid."); |
| 245 | +#endif |
228 | 246 | #else
|
229 | 247 | #ifdef INFINITY
|
230 | 248 | #error "Macro INFINITY should not be defined."
|
@@ -271,8 +289,14 @@ _Static_assert(FLT_MAX_10_EXP == __FLT_MAX_10_EXP__, "");
|
271 | 289 | _Static_assert(DBL_MAX_10_EXP == __DBL_MAX_10_EXP__, "");
|
272 | 290 | _Static_assert(LDBL_MAX_10_EXP == __LDBL_MAX_10_EXP__, "");
|
273 | 291 |
|
274 |
| -#if (__STDC_VERSION__ >= 202311L || !defined(__STRICT_ANSI__)) && __FINITE_MATH_ONLY__ == 0 |
| 292 | +#if __STDC_VERSION__ >= 202311L || !defined(__STRICT_ANSI__) |
| 293 | +_Static_assert(FLT_NORM_MAX == __FLT_NORM_MAX__, ""); |
| 294 | +_Static_assert(DBL_NORM_MAX == __DBL_NORM_MAX__, ""); |
| 295 | +_Static_assert(LDBL_NORM_MAX == __LDBL_NORM_MAX__, ""); |
| 296 | + |
| 297 | +#if __FINITE_MATH_ONLY__ == 0 |
275 | 298 | // Ensure INFINITY and NAN are suitable for use in a constant expression.
|
276 | 299 | float f1 = INFINITY;
|
277 | 300 | float f2 = NAN;
|
278 | 301 | #endif
|
| 302 | +#endif |
0 commit comments