compiler: Correct handling of negative zero floating constant.
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 23 Apr 2012 20:49:33 +0000 (20:49 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 23 Apr 2012 20:49:33 +0000 (20:49 +0000)
From-SVN: r186722

gcc/go/gofrontend/expressions.cc

index cb94e4f8dd9d322bf7edc6d9ebe94bbf3d3dd9ed..945f379465ae161fd91127145f180b1e3aab65ae 100644 (file)
@@ -13620,7 +13620,13 @@ Numeric_constant::set_float(Type* type, const mpfr_t val)
   this->clear();
   this->classification_ = NC_FLOAT;
   this->type_ = type;
-  mpfr_init_set(this->u_.float_val, val, GMP_RNDN);
+  // Numeric constants do not have negative zero values, so remove
+  // them here.  They also don't have infinity or NaN values, but we
+  // should never see them here.
+  if (mpfr_zero_p(val))
+    mpfr_init_set_ui(this->u_.float_val, 0, GMP_RNDN);
+  else
+    mpfr_init_set(this->u_.float_val, val, GMP_RNDN);
 }
 
 // Set to a complex value.