From: Joseph Myers Date: Tue, 17 Nov 2020 16:30:35 +0000 (+0000) Subject: float.h: Handle C2x __STDC_WANT_IEC_60559_EXT__ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ffd8e34d182c2c206d8d1543b72e489d6f4b385;p=gcc.git float.h: Handle C2x __STDC_WANT_IEC_60559_EXT__ TS 18661-1 and 18661-2 have various definitions conditional on __STDC_WANT_IEC_60559_BFP_EXT__ and __STDC_WANT_IEC_60559_DFP_EXT__ macros. When those TSes were integrated into C2x, most of the feature test macro conditionals were removed (with declarations for decimal FP becoming conditional only on whether decimal FP is supported by the implementation and those for binary FP becoming unconditionally required). A few tests of those feature test macros remained for declarations that appeared only in Annex F and not in the main part of the standard. A change accepted for C2x at the last WG14 meeting (but not yet added to the working draft in git) was to replace both those macros by __STDC_WANT_IEC_60559_EXT__; if __STDC_WANT_IEC_60559_EXT__ is defined, the specific declarations in the headers will then depend on which features are supported by the implementation, as for declarations not controlled by a feature test macro at all. Thus, add a check of __STDC_WANT_IEC_60559_EXT__ for CR_DECIMAL_DIG in float.h, the only case of this change relevant to GCC. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/ 2020-11-17 Joseph Myers * ginclude/float.h (CR_DECIMAL_DIG): Also define for [__STDC_WANT_IEC_60559_EXT__]. gcc/testsuite/ 2020-11-17 Joseph Myers * gcc.dg/cr-decimal-dig-3.c: New test. --- diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h index 83c5ad55a53..39139ee8dd1 100644 --- a/gcc/ginclude/float.h +++ b/gcc/ginclude/float.h @@ -285,7 +285,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif /* C2X */ -#ifdef __STDC_WANT_IEC_60559_BFP_EXT__ +#if (defined __STDC_WANT_IEC_60559_BFP_EXT__ \ + || defined __STDC_WANT_IEC_60559_EXT__) /* Number of decimal digits for which conversions between decimal character strings and binary formats, in both directions, are correctly rounded. */ diff --git a/gcc/testsuite/gcc.dg/cr-decimal-dig-3.c b/gcc/testsuite/gcc.dg/cr-decimal-dig-3.c new file mode 100644 index 00000000000..8e07b67dd52 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cr-decimal-dig-3.c @@ -0,0 +1,14 @@ +/* Test C2x CR_DECIMAL_DIG: defined for __STDC_WANT_IEC_60559_EXT__. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#define __STDC_WANT_IEC_60559_EXT__ +#include + +#ifndef CR_DECIMAL_DIG +#error "CR_DECIMAL_DIG not defined" +#endif + +#if CR_DECIMAL_DIG < DECIMAL_DIG + 3 +#error "CR_DECIMAL_DIG too small" +#endif