compiler: check for floating-point exponent overflow
Adjust mksysinfo and mkrsysinfo to strip out floating-point max numbers,
as they can trigger this error.
Change-Id: If453722c6c149976f69a440d427180e810138326
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/278476
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/go/lex.cc b/go/lex.cc
index e71b8cd..0baf4e4 100644
--- a/go/lex.cc
+++ b/go/lex.cc
@@ -1316,9 +1316,13 @@
}
}
+ mpfr_clear_overflow();
mpfr_t val;
int r = mpfr_init_set_str(val, num.c_str(), base, MPFR_RNDN);
go_assert(r == 0);
+ if (mpfr_overflow_p())
+ go_error_at(this->location(),
+ "floating-point exponent too large to represent");
bool is_imaginary = *p == 'i';
if (is_imaginary)
diff --git a/libgo/mkrsysinfo.sh b/libgo/mkrsysinfo.sh
index c28f0e5..e016ca4 100755
--- a/libgo/mkrsysinfo.sh
+++ b/libgo/mkrsysinfo.sh
@@ -26,6 +26,7 @@
grep -v '^type _*locale[_ ]' | \
grep -v 'in6_addr' | \
grep -v 'sockaddr_in6' | \
+ egrep -v '^const _*FLT(64|128)_(NORM_)?MAX' | \
sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1timeval\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1timespec\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1timespec\2/g' \
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index b32a026..24d4ce2 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -38,6 +38,7 @@
grep -v '^type _*locale[_ ]' | \
grep -v 'in6_addr' | \
grep -v 'sockaddr_in6' | \
+ egrep -v '^const _*FLT(64|128)_(NORM_)?MAX' | \
sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \