OSDN Git Service

compiler: Correct handling of negative zero floating constant.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Apr 2012 20:49:47 +0000 (20:49 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Apr 2012 20:49:47 +0000 (20:49 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186723 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc

index cb94e4f..945f379 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.