diff options
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-cppbuiltin.c | 14 | ||||
-rw-r--r-- | gcc/ginclude/float.h | 47 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c11-float-dfp-1.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c2x-float-no-dfp-1.c | 101 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c2x-float-no-dfp-2.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-1.c | 103 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-2.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-3.c | 103 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/tr24732-float-dfp-1.c | 106 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/ts18661-2-float-dfp-1.c | 8 |
13 files changed, 512 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b9bcaba..3d9af72 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2019-10-10 Joseph Myers <joseph@codesourcery.com> + + * ginclude/float.h [!__DEC32_MANT_DIG__]: Do not define DFP + macros. + [__STDC_WANT_IEC_60559_DFP_EXT__ || __STDC_VERSION__ > 201710L]: + Also define DFP macros for these conditions. + [!__STDC_WANT_DEC_FP__] (DEC32_SUBNORMAL_MIN, DEC64_SUBNORMAL_MIN, + DEC128_SUBNORMAL_MIN): Do not define. + [__STDC_WANT_IEC_60559_DFP_EXT__ || __STDC_VERSION__ > 201710L] + (DEC32_TRUE_MIN, DEC64_TRUE_MIN, DEC128_TRUE_MIN): New macros. + 2019-10-10 Xiong Hu Luo <luoxhu@linux.ibm.com> Sandra Loosemore <sandra@codesourcery.com> diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 598fea4..a41e910 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2019-10-10 Joseph Myers <joseph@codesourcery.com> + + * c-cppbuiltin.c (c_cpp_builtins): Do not define macros for DFP + types if DFP not supported. + 2019-10-10 Jakub Jelinek <jakub@redhat.com> * c-common.h (c_omp_check_context_selector, diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index d9941e7..8a66c91 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -1151,10 +1151,16 @@ c_cpp_builtins (cpp_reader *pfile) csuffix, FLOATN_NX_TYPE_NODE (i)); } - /* For decfloat.h. */ - builtin_define_decimal_float_constants ("DEC32", "DF", dfloat32_type_node); - builtin_define_decimal_float_constants ("DEC64", "DD", dfloat64_type_node); - builtin_define_decimal_float_constants ("DEC128", "DL", dfloat128_type_node); + /* For float.h. */ + if (targetm.decimal_float_supported_p ()) + { + builtin_define_decimal_float_constants ("DEC32", "DF", + dfloat32_type_node); + builtin_define_decimal_float_constants ("DEC64", "DD", + dfloat64_type_node); + builtin_define_decimal_float_constants ("DEC128", "DL", + dfloat128_type_node); + } /* For fixed-point fibt, ibit, max, min, and epsilon. */ if (targetm.fixed_point_supported_p ()) diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h index 4767d7b..dc91c75 100644 --- a/gcc/ginclude/float.h +++ b/gcc/ginclude/float.h @@ -426,9 +426,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__. */ -#ifdef __STDC_WANT_DEC_FP__ -/* Draft Technical Report 24732, extension for decimal floating-point - arithmetic: Characteristic of decimal floating types <float.h>. */ +#ifdef __DEC32_MANT_DIG__ +#if (defined __STDC_WANT_DEC_FP__ \ + || defined __STDC_WANT_IEC_60559_DFP_EXT__ \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L)) +/* C2X; formerly Technical Report 24732, extension for decimal + floating-point arithmetic: Characteristic of decimal floating types + <float.h>, and TS 18661-2. */ /* Number of base-FLT_RADIX digits in the significand, p. */ #undef DEC32_MANT_DIG @@ -480,14 +484,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define DEC64_MIN __DEC64_MIN__ #define DEC128_MIN __DEC128_MIN__ -/* Minimum subnormal positive floating-point number. */ -#undef DEC32_SUBNORMAL_MIN -#undef DEC64_SUBNORMAL_MIN -#undef DEC128_SUBNORMAL_MIN -#define DEC32_SUBNORMAL_MIN __DEC32_SUBNORMAL_MIN__ -#define DEC64_SUBNORMAL_MIN __DEC64_SUBNORMAL_MIN__ -#define DEC128_SUBNORMAL_MIN __DEC128_SUBNORMAL_MIN__ - /* The floating-point expression evaluation method. -1 indeterminate 0 evaluate all operations and constants just to the range and @@ -502,6 +498,33 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #undef DEC_EVAL_METHOD #define DEC_EVAL_METHOD __DEC_EVAL_METHOD__ -#endif /* __STDC_WANT_DEC_FP__ */ +#endif /* __STDC_WANT_DEC_FP__ || __STDC_WANT_IEC_60559_DFP_EXT__ || C2X. */ + +#ifdef __STDC_WANT_DEC_FP__ + +/* Minimum subnormal positive floating-point number. */ +#undef DEC32_SUBNORMAL_MIN +#undef DEC64_SUBNORMAL_MIN +#undef DEC128_SUBNORMAL_MIN +#define DEC32_SUBNORMAL_MIN __DEC32_SUBNORMAL_MIN__ +#define DEC64_SUBNORMAL_MIN __DEC64_SUBNORMAL_MIN__ +#define DEC128_SUBNORMAL_MIN __DEC128_SUBNORMAL_MIN__ + +#endif /* __STDC_WANT_DEC_FP__. */ + +#if (defined __STDC_WANT_IEC_60559_DFP_EXT__ \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L)) + +/* Minimum subnormal positive floating-point number. */ +#undef DEC32_TRUE_MIN +#undef DEC64_TRUE_MIN +#undef DEC128_TRUE_MIN +#define DEC32_TRUE_MIN __DEC32_SUBNORMAL_MIN__ +#define DEC64_TRUE_MIN __DEC64_SUBNORMAL_MIN__ +#define DEC128_TRUE_MIN __DEC128_SUBNORMAL_MIN__ + +#endif /* __STDC_WANT_IEC_60559_DFP_EXT__ || C2X. */ + +#endif /* __DEC32_MANT_DIG__ */ #endif /* _FLOAT_H___ */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c3f5880..76e634e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-10-10 Joseph Myers <joseph@codesourcery.com> + + * gcc.dg/c11-float-dfp-1.c, gcc.dg/c2x-float-no-dfp-1.c, + gcc.dg/c2x-float-no-dfp-2.c, gcc.dg/dfp/c2x-float-dfp-1.c, + gcc.dg/dfp/c2x-float-dfp-2.c, gcc.dg/dfp/c2x-float-dfp-3.c, + gcc.dg/dfp/tr24732-float-dfp-1.c, + gcc.dg/dfp/ts18661-2-float-dfp-1.c: New tests. + 2019-10-10 David Malcolm <dmalcolm@redhat.com> PR 87488 diff --git a/gcc/testsuite/gcc.dg/c11-float-dfp-1.c b/gcc/testsuite/gcc.dg/c11-float-dfp-1.c new file mode 100644 index 0000000..8d86b1b --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-float-dfp-1.c @@ -0,0 +1,5 @@ +/* Test DFP macros not defined in <float.h> for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#include "c2x-float-no-dfp-1.c" diff --git a/gcc/testsuite/gcc.dg/c2x-float-no-dfp-1.c b/gcc/testsuite/gcc.dg/c2x-float-no-dfp-1.c new file mode 100644 index 0000000..73610c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-float-no-dfp-1.c @@ -0,0 +1,101 @@ +/* Test DFP macros not defined in <float.h> if no DFP support. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +#include <float.h> + +#ifdef DEC32_MANT_DIG +# error "DEC32_MANT_DIG defined" +#endif + +#ifdef DEC64_MANT_DIG +# error "DEC64_MANT_DIG defined" +#endif + +#ifdef DEC128_MANT_DIG +# error "DEC128_MANT_DIG defined" +#endif + +#ifdef DEC32_MIN_EXP +# error "DEC32_MIN_EXP defined" +#endif + +#ifdef DEC64_MIN_EXP +# error "DEC64_MIN_EXP defined" +#endif + +#ifdef DEC128_MIN_EXP +# error "DEC128_MIN_EXP defined" +#endif + +#ifdef DEC32_MAX_EXP +# error "DEC32_MAX_EXP defined" +#endif + +#ifdef DEC64_MAX_EXP +# error "DEC64_MAX_EXP defined" +#endif + +#ifdef DEC128_MAX_EXP +# error "DEC128_MAX_EXP defined" +#endif + +#ifdef DEC32_MAX +# error "DEC32_MAX defined" +#endif + +#ifdef DEC64_MAX +# error "DEC64_MAX defined" +#endif + +#ifdef DEC128_MAX +# error "DEC128_MAX defined" +#endif + +#ifdef DEC32_EPSILON +# error "DEC32_EPSILON defined" +#endif + +#ifdef DEC64_EPSILON +# error "DEC64_EPSILON defined" +#endif + +#ifdef DEC128_EPSILON +# error "DEC128_EPSILON defined" +#endif + +#ifdef DEC32_MIN +# error "DEC32_MIN defined" +#endif + +#ifdef DEC64_MIN +# error "DEC64_MIN defined" +#endif + +#ifdef DEC128_MIN +# error "DEC128_MIN defined" +#endif + +#ifdef DEC32_TRUE_MIN +# error "DEC32_TRUE_MIN defined" +#endif + +#ifdef DEC64_TRUE_MIN +# error "DEC64_TRUE_MIN defined" +#endif + +#ifdef DEC128_TRUE_MIN +# error "DEC128_TRUE_MIN defined" +#endif + +#ifdef DEC32_SUBNORMAL_MIN +# error "DEC32_SUBNORMAL_MIN defined" +#endif + +#ifdef DEC64_SUBNORMAL_MIN +# error "DEC64_SUBNORMAL_MIN defined" +#endif + +#ifdef DEC128_SUBNORMAL_MIN +# error "DEC128_SUBNORMAL_MIN defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-float-no-dfp-2.c b/gcc/testsuite/gcc.dg/c2x-float-no-dfp-2.c new file mode 100644 index 0000000..730ce89 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-float-no-dfp-2.c @@ -0,0 +1,9 @@ +/* Test DFP macros not defined in <float.h> if no DFP support. Test + with feature test macros defined. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +#define __STDC_WANT_DEC_FP__ +#define __STDC_WANT_IEC_60559_DFP_EXT__ + +#include "c2x-float-no-dfp-1.c" diff --git a/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-1.c b/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-1.c new file mode 100644 index 0000000..ee5e678 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-1.c @@ -0,0 +1,103 @@ +/* Test DFP macros defined in <float.h> with DFP support. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#include <float.h> + +#ifndef DEC32_MANT_DIG +# error "DEC32_MANT_DIG not defined" +#endif + +#ifndef DEC64_MANT_DIG +# error "DEC64_MANT_DIG not defined" +#endif + +#ifndef DEC128_MANT_DIG +# error "DEC128_MANT_DIG not defined" +#endif + +#ifndef DEC32_MIN_EXP +# error "DEC32_MIN_EXP not defined" +#endif + +#ifndef DEC64_MIN_EXP +# error "DEC64_MIN_EXP not defined" +#endif + +#ifndef DEC128_MIN_EXP +# error "DEC128_MIN_EXP not defined" +#endif + +#ifndef DEC32_MAX_EXP +# error "DEC32_MAX_EXP not defined" +#endif + +#ifndef DEC64_MAX_EXP +# error "DEC64_MAX_EXP not defined" +#endif + +#ifndef DEC128_MAX_EXP +# error "DEC128_MAX_EXP not defined" +#endif + +#ifndef DEC32_MAX +# error "DEC32_MAX not defined" +#endif + +#ifndef DEC64_MAX +# error "DEC64_MAX not defined" +#endif + +#ifndef DEC128_MAX +# error "DEC128_MAX not defined" +#endif + +#ifndef DEC32_EPSILON +# error "DEC32_EPSILON not defined" +#endif + +#ifndef DEC64_EPSILON +# error "DEC64_EPSILON not defined" +#endif + +#ifndef DEC128_EPSILON +# error "DEC128_EPSILON not defined" +#endif + +#ifndef DEC32_MIN +# error "DEC32_MIN not defined" +#endif + +#ifndef DEC64_MIN +# error "DEC64_MIN not defined" +#endif + +#ifndef DEC128_MIN +# error "DEC128_MIN not defined" +#endif + +#ifndef DEC32_TRUE_MIN +# error "DEC32_TRUE_MIN not defined" +#endif + +#ifndef DEC64_TRUE_MIN +# error "DEC64_TRUE_MIN not defined" +#endif + +#ifndef DEC128_TRUE_MIN +# error "DEC128_TRUE_MIN not defined" +#endif + +/* These macros from TR 24732 should not be defined. */ + +#ifdef DEC32_SUBNORMAL_MIN +# error "DEC32_SUBNORMAL_MIN defined" +#endif + +#ifdef DEC64_SUBNORMAL_MIN +# error "DEC64_SUBNORMAL_MIN defined" +#endif + +#ifdef DEC128_SUBNORMAL_MIN +# error "DEC128_SUBNORMAL_MIN defined" +#endif diff --git a/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-2.c b/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-2.c new file mode 100644 index 0000000..9ba5690 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-2.c @@ -0,0 +1,8 @@ +/* Test DFP macros defined in <float.h> with DFP support. TS 18661-2 + feature test macro does not change what is defined. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#define __STDC_WANT_IEC_60559_DFP_EXT__ + +#include "c2x-float-dfp-1.c" diff --git a/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-3.c b/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-3.c new file mode 100644 index 0000000..00b51a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/c2x-float-dfp-3.c @@ -0,0 +1,103 @@ +/* Test DFP macros defined in <float.h> with DFP support. TR 24732 + feature test macro causes *_SUBNORMAL_MIN macros to be defined. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#define __STDC_WANT_DEC_FP__ +#include <float.h> + +#ifndef DEC32_MANT_DIG +# error "DEC32_MANT_DIG not defined" +#endif + +#ifndef DEC64_MANT_DIG +# error "DEC64_MANT_DIG not defined" +#endif + +#ifndef DEC128_MANT_DIG +# error "DEC128_MANT_DIG not defined" +#endif + +#ifndef DEC32_MIN_EXP +# error "DEC32_MIN_EXP not defined" +#endif + +#ifndef DEC64_MIN_EXP +# error "DEC64_MIN_EXP not defined" +#endif + +#ifndef DEC128_MIN_EXP +# error "DEC128_MIN_EXP not defined" +#endif + +#ifndef DEC32_MAX_EXP +# error "DEC32_MAX_EXP not defined" +#endif + +#ifndef DEC64_MAX_EXP +# error "DEC64_MAX_EXP not defined" +#endif + +#ifndef DEC128_MAX_EXP +# error "DEC128_MAX_EXP not defined" +#endif + +#ifndef DEC32_MAX +# error "DEC32_MAX not defined" +#endif + +#ifndef DEC64_MAX +# error "DEC64_MAX not defined" +#endif + +#ifndef DEC128_MAX +# error "DEC128_MAX not defined" +#endif + +#ifndef DEC32_EPSILON +# error "DEC32_EPSILON not defined" +#endif + +#ifndef DEC64_EPSILON +# error "DEC64_EPSILON not defined" +#endif + +#ifndef DEC128_EPSILON +# error "DEC128_EPSILON not defined" +#endif + +#ifndef DEC32_MIN +# error "DEC32_MIN not defined" +#endif + +#ifndef DEC64_MIN +# error "DEC64_MIN not defined" +#endif + +#ifndef DEC128_MIN +# error "DEC128_MIN not defined" +#endif + +#ifndef DEC32_TRUE_MIN +# error "DEC32_TRUE_MIN not defined" +#endif + +#ifndef DEC64_TRUE_MIN +# error "DEC64_TRUE_MIN not defined" +#endif + +#ifndef DEC128_TRUE_MIN +# error "DEC128_TRUE_MIN not defined" +#endif + +#ifndef DEC32_SUBNORMAL_MIN +# error "DEC32_SUBNORMAL_MIN not defined" +#endif + +#ifndef DEC64_SUBNORMAL_MIN +# error "DEC64_SUBNORMAL_MIN not defined" +#endif + +#ifndef DEC128_SUBNORMAL_MIN +# error "DEC128_SUBNORMAL_MIN not defined" +#endif diff --git a/gcc/testsuite/gcc.dg/dfp/tr24732-float-dfp-1.c b/gcc/testsuite/gcc.dg/dfp/tr24732-float-dfp-1.c new file mode 100644 index 0000000..c196816 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/tr24732-float-dfp-1.c @@ -0,0 +1,106 @@ +/* Test DFP macros defined in <float.h> with DFP support. TR 24732 + feature test macro causes SUBNORMAL_MIN macros to be defined but + not TRUE_MIN ones. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +#define __STDC_WANT_DEC_FP__ +#include <float.h> + +#ifndef DEC32_MANT_DIG +# error "DEC32_MANT_DIG not defined" +#endif + +#ifndef DEC64_MANT_DIG +# error "DEC64_MANT_DIG not defined" +#endif + +#ifndef DEC128_MANT_DIG +# error "DEC128_MANT_DIG not defined" +#endif + +#ifndef DEC32_MIN_EXP +# error "DEC32_MIN_EXP not defined" +#endif + +#ifndef DEC64_MIN_EXP +# error "DEC64_MIN_EXP not defined" +#endif + +#ifndef DEC128_MIN_EXP +# error "DEC128_MIN_EXP not defined" +#endif + +#ifndef DEC32_MAX_EXP +# error "DEC32_MAX_EXP not defined" +#endif + +#ifndef DEC64_MAX_EXP +# error "DEC64_MAX_EXP not defined" +#endif + +#ifndef DEC128_MAX_EXP +# error "DEC128_MAX_EXP not defined" +#endif + +#ifndef DEC32_MAX +# error "DEC32_MAX not defined" +#endif + +#ifndef DEC64_MAX +# error "DEC64_MAX not defined" +#endif + +#ifndef DEC128_MAX +# error "DEC128_MAX not defined" +#endif + +#ifndef DEC32_EPSILON +# error "DEC32_EPSILON not defined" +#endif + +#ifndef DEC64_EPSILON +# error "DEC64_EPSILON not defined" +#endif + +#ifndef DEC128_EPSILON +# error "DEC128_EPSILON not defined" +#endif + +#ifndef DEC32_MIN +# error "DEC32_MIN not defined" +#endif + +#ifndef DEC64_MIN +# error "DEC64_MIN not defined" +#endif + +#ifndef DEC128_MIN +# error "DEC128_MIN not defined" +#endif + +#ifndef DEC32_SUBNORMAL_MIN +# error "DEC32_SUBNORMAL_MIN not defined" +#endif + +#ifndef DEC64_SUBNORMAL_MIN +# error "DEC64_SUBNORMAL_MIN not defined" +#endif + +#ifndef DEC128_SUBNORMAL_MIN +# error "DEC128_SUBNORMAL_MIN not defined" +#endif + +/* These macros from C2X should not be defined. */ + +#ifdef DEC32_TRUE_MIN +# error "DEC32_TRUE_MIN defined" +#endif + +#ifdef DEC64_TRUE_MIN +# error "DEC64_TRUE_MIN defined" +#endif + +#ifdef DEC128_TRUE_MIN +# error "DEC128_TRUE_MIN defined" +#endif diff --git a/gcc/testsuite/gcc.dg/dfp/ts18661-2-float-dfp-1.c b/gcc/testsuite/gcc.dg/dfp/ts18661-2-float-dfp-1.c new file mode 100644 index 0000000..f0a0824 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/ts18661-2-float-dfp-1.c @@ -0,0 +1,8 @@ +/* Test DFP macros defined in <float.h> with DFP support. TS 18661-2 + feature test macro causes same macros to be defined as for C2X. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +#define __STDC_WANT_IEC_60559_DFP_EXT__ + +#include "c2x-float-dfp-1.c" |