aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-cppbuiltin.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2020-11-17 16:25:45 +0000
committerJoseph Myers <joseph@codesourcery.com>2020-11-17 16:28:11 +0000
commitac30c8b8d035cd9259040150f059f1cf3542f626 (patch)
tree74a267e1b58daaf2b2dc87c438f06a7bc7d88b5d /gcc/c-family/c-cppbuiltin.c
parent8895913273b97d07f9576f5eb497d39b78166daf (diff)
downloadgcc-ac30c8b8d035cd9259040150f059f1cf3542f626.zip
gcc-ac30c8b8d035cd9259040150f059f1cf3542f626.tar.gz
gcc-ac30c8b8d035cd9259040150f059f1cf3542f626.tar.bz2
float.h: C2x *_IS_IEC_60559 macros
C2x adds float.h macros that say whether float, double and long double match an IEC 60559 (IEEE 754) format and operations. Add these macros to GCC's float.h. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c-family/ 2020-11-17 Joseph Myers <joseph@codesourcery.com> * c-cppbuiltin.c (builtin_define_float_constants): Define "*_IS_IEC_60559__" macros. gcc/ 2020-11-17 Joseph Myers <joseph@codesourcery.com> * ginclude/float.h [__STDC_VERSION__ > 201710L] (FLT_IS_IEC_60559, DBL_IS_IEC_60559, LDBL_IS_IEC_60559): New macros. gcc/testsuite/ 2020-11-17 Joseph Myers <joseph@codesourcery.com> * gcc.dg/c11-float-6.c, gcc.dg/c2x-float-10.c: New tests.
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.c')
-rw-r--r--gcc/c-family/c-cppbuiltin.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 8856a97..d35b087 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -317,6 +317,16 @@ builtin_define_float_constants (const char *name_prefix,
sprintf (name, "__FP_FAST_FMA%s", fma_suffix);
builtin_define_with_int_value (name, 1);
}
+
+ /* For C2x *_IS_IEC_60559. 0 means the type does not match an IEC
+ 60559 format, 1 that it matches a format but not operations and 2
+ that it matches a format and operations (but may not conform to
+ Annex F; we take this as meaning exceptions and rounding modes
+ need not be supported). */
+ sprintf (name, "__%s_IS_IEC_60559__", name_prefix);
+ builtin_define_with_int_value (name,
+ (fmt->ieee_bits == 0
+ ? 0 : (fmt->round_towards_zero ? 1 : 2)));
}
/* Define __DECx__ constants for TYPE using NAME_PREFIX and SUFFIX. */