aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-05-27 10:16:13 -0700
committerRuss Cox <rsc@golang.org>2009-05-27 10:16:13 -0700
commit18890eebbf27fec3b004478fc23443bbd349ba6d (patch)
tree9db8695574ff30e1437fd88ba4c6acdbfed3670e /src
parent5f460b38f9190f1a62b0575289511341849dfb10 (diff)
downloadgo-18890eebbf27fec3b004478fc23443bbd349ba6d.tar.xz
fix bug154; tweak bug153 exit status
R=ken OCL=29448 CL=29448
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/const.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c
index 5dbacece7e..33acec6fc4 100644
--- a/src/cmd/gc/const.c
+++ b/src/cmd/gc/const.c
@@ -13,16 +13,20 @@ static Val copyval(Val);
/*
* truncate float literal fv to 32-bit or 64-bit precision
- * according to type.
+ * according to type; return truncated value.
*/
-void
-truncfltlit(Mpflt *fv, Type *t)
+Mpflt*
+truncfltlit(Mpflt *oldv, Type *t)
{
double d;
float f;
+ Mpflt *fv;
if(t == T)
- return;
+ return oldv;
+
+ fv = mal(sizeof *fv);
+ *fv = *oldv;
// convert large precision literal floating
// into limited precision (float64 or float32)
@@ -41,6 +45,7 @@ truncfltlit(Mpflt *fv, Type *t)
mpmovecflt(fv, d);
break;
}
+ return fv;
}
/*
@@ -154,7 +159,7 @@ convlit1(Node *n, Type *t, int explicit)
else if(ct != CTFLT)
goto bad;
overflow(n->val, t);
- truncfltlit(n->val.u.fval, t);
+ n->val.u.fval = truncfltlit(n->val.u.fval, t);
} else if(et == TSTRING && ct == CTINT && explicit)
n->val = tostr(n->val);
else
@@ -607,7 +612,7 @@ ret:
// truncate precision for non-ideal float.
if(v.ctype == CTFLT && n->type->etype != TIDEAL)
- truncfltlit(v.u.fval, n->type);
+ n->val.u.fval = truncfltlit(v.u.fval, n->type);
return;
settrue: