float.h: C2x NaN and Inf macros
authorJoseph Myers <joseph@codesourcery.com>
Tue, 17 Nov 2020 00:25:12 +0000 (00:25 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 17 Nov 2020 00:25:12 +0000 (00:25 +0000)
commit3cfe746fc5255f8dd1674bf4a8873b7b8e178c89
treef0d2a626b8a10362ae2d8a09ba7ed66879fbf81b
parent29c5d9ceb9bf7416b6f6b976879ac0dc60701904
float.h: C2x NaN and Inf macros

C2x adds macros for NaNs and infinities to <float.h>, some of them
previously in <math.h> (and some still in <math.h> as well in C2x as
an obsolescent feature).  Add these macros to GCC's <float.h>
implementation.

This omits the macros for DFP signaling NaNs, leaving those to be
added in a separate patch.  However, it includes the _FloatN /
_FloatNx macros (conditional on __STDC_WANT_IEC_60559_TYPES_EXT__) in
the current draft version of the integration of TS 18661-3 into C2x as
an Annex.

As GCC allows duplicate macro definitions with different expansions in
system headers, it should be OK if <math.h> defines INFINITY or NAN
with a slightly different expansion (e.g. different choice of whether
there is whitespace between tokens); tests are added including
<float.h> and <math.h> in either order.  Because <float.h> uses #undef
on all macros before defining them, even with -Wsystem-headers there
could only ever be issues when <math.h> is included after <float.h>.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* ginclude/float.h (INFINITY, NAN, FLT_SNAN, DBL_SNAN, LDBL_SNAN)
(FLT16_SNAN, FLT32_SNAN, FLT64_SNAN, FLT128_SNAN, FLT32X_SNAN)
(FLT64X_SNAN, FLT128X_SNAN, DEC_INFINITY, DEC_NAN): New C2x
macros.
* doc/sourcebuild.texi (Effective-Target Keywords): Document inff.

gcc/testsuite/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* lib/target-supports.exp (check_effective_target_inff): New.
* gcc.dg/c11-float-4.c, gcc.dg/c11-float-5.c,
gcc.dg/c11-float-dfp-2.c, gcc.dg/c2x-float-2.c,
gcc.dg/c2x-float-3.c, gcc.dg/c2x-float-4.c, gcc.dg/c2x-float-5.c,
gcc.dg/c2x-float-6.c, gcc.dg/c2x-float-7.c, gcc.dg/c2x-float-8.c,
gcc.dg/c2x-float-9.c, gcc.dg/c2x-float-no-dfp-3.c,
gcc.dg/c2x-float-no-dfp-4.c, gcc.dg/dfp/c2x-float-dfp-4.c,
gcc.dg/dfp/c2x-float-dfp-5.c, gcc.dg/dfp/c2x-float-dfp-6.c,
gcc.dg/torture/float128-nan-floath.c,
gcc.dg/torture/float128x-nan-floath.c,
gcc.dg/torture/float16-nan-floath.c,
gcc.dg/torture/float32-nan-floath.c,
gcc.dg/torture/float32x-nan-floath.c,
gcc.dg/torture/float64-nan-floath.c,
gcc.dg/torture/float64x-nan-floath.c,
gcc.dg/torture/floatn-nan-floath.h: New tests.
27 files changed:
gcc/doc/sourcebuild.texi
gcc/ginclude/float.h
gcc/testsuite/gcc.dg/c11-float-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c11-float-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c11-float-dfp-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-9.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-no-dfp-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c2x-float-no-dfp-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float128-nan-floath.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float128x-nan-floath.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float16-nan-floath.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float32-nan-floath.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float32x-nan-floath.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float64-nan-floath.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float64x-nan-floath.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/floatn-nan-floath.h [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp