aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/go-lang.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-12-21 16:17:23 -0800
committerIan Lance Taylor <iant@golang.org>2020-12-21 16:18:02 -0800
commit03ea48ff27fd40b04b148f7006a02513a887ad0d (patch)
tree826967960387c901560432d71b56586654671f97 /gcc/go/go-lang.c
parent1a5e728a544e216fc222f61bcc602b0aadd56eb9 (diff)
downloadgcc-03ea48ff27fd40b04b148f7006a02513a887ad0d.zip
gcc-03ea48ff27fd40b04b148f7006a02513a887ad0d.tar.gz
gcc-03ea48ff27fd40b04b148f7006a02513a887ad0d.tar.bz2
Go frontend: ensure mpfr exponent range is large enough for Go
PR go/98402 * go-lang.c (go_langhook_init): Force MPFR exponent range to be large enough to support Go constants.
Diffstat (limited to 'gcc/go/go-lang.c')
-rw-r--r--gcc/go/go-lang.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c
index 08c1f38..9c0e7af 100644
--- a/gcc/go/go-lang.c
+++ b/gcc/go/go-lang.c
@@ -131,6 +131,16 @@ go_langhook_init (void)
eventually be controllable by a command line option. */
mpfr_set_default_prec (256);
+ /* If necessary, override GCC's choice of minimum and maximum
+ exponents. This should only affect GCC middle-end
+ compilation-time, not correctness. */
+ mpfr_exp_t exp = mpfr_get_emax ();
+ if (exp < (1 << 16) - 1)
+ mpfr_set_emax ((1 << 16) - 1);
+ exp = mpfr_get_emin ();
+ if (exp > - ((1 << 16) - 1))
+ mpfr_set_emin (- ((1 << 16) - 1));
+
/* Go uses exceptions. */
using_eh_for_cleanups ();