This patch to the Go frontend changes it to use mpfr_prec_round rather
than real_convert to constrain untyped float or complex constants to
their actual type.  This is a simplification and also eliminates a call
from the frontend to a gcc-specific middle-end function.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

diff -r f05cc4c5ad22 go/expressions.cc
--- a/go/expressions.cc	Tue Apr 19 16:19:05 2011 -0700
+++ b/go/expressions.cc	Wed Apr 20 22:52:36 2011 -0700
@@ -1909,13 +1909,7 @@
 {
   Float_type* ftype = type->float_type();
   if (ftype != NULL && !ftype->is_abstract())
-    {
-      tree type_tree = ftype->type_tree();
-      REAL_VALUE_TYPE rvt;
-      real_from_mpfr(&rvt, val, type_tree, GMP_RNDN);
-      real_convert(&rvt, TYPE_MODE(type_tree), &rvt);
-      mpfr_from_real(val, &rvt, GMP_RNDN);
-    }
+    mpfr_prec_round(val, ftype->bits(), GMP_RNDN);
 }
 
 // Return a floating point constant value.
@@ -2158,16 +2152,8 @@
   Complex_type* ctype = type->complex_type();
   if (ctype != NULL && !ctype->is_abstract())
     {
-      tree type_tree = ctype->type_tree();
-
-      REAL_VALUE_TYPE rvt;
-      real_from_mpfr(&rvt, real, TREE_TYPE(type_tree), GMP_RNDN);
-      real_convert(&rvt, TYPE_MODE(TREE_TYPE(type_tree)), &rvt);
-      mpfr_from_real(real, &rvt, GMP_RNDN);
-
-      real_from_mpfr(&rvt, imag, TREE_TYPE(type_tree), GMP_RNDN);
-      real_convert(&rvt, TYPE_MODE(TREE_TYPE(type_tree)), &rvt);
-      mpfr_from_real(imag, &rvt, GMP_RNDN);
+      mpfr_prec_round(real, ctype->bits() / 2, GMP_RNDN);
+      mpfr_prec_round(imag, ctype->bits() / 2, GMP_RNDN);
     }
 }
 

Reply via email to