Commit 83feedf7 authored by Russ Cox's avatar Russ Cox

gc: fix error for floating-point constant %

R=ken2
CC=golang-dev
https://golang.org/cl/5674108
parent 03f2289f
...@@ -660,6 +660,14 @@ evconst(Node *n) ...@@ -660,6 +660,14 @@ evconst(Node *n)
} }
mpdivfltflt(v.u.fval, rv.u.fval); mpdivfltflt(v.u.fval, rv.u.fval);
break; break;
case TUP(OMOD, CTFLT):
// The default case above would print 'ideal % ideal',
// which is not quite an ideal error.
if(!n->diag) {
yyerror("illegal constant expression: floating-point %% operation");
n->diag = 1;
}
return;
case TUP(OADD, CTCPLX): case TUP(OADD, CTCPLX):
mpaddfltflt(&v.u.cval->real, &rv.u.cval->real); mpaddfltflt(&v.u.cval->real, &rv.u.cval->real);
mpaddfltflt(&v.u.cval->imag, &rv.u.cval->imag); mpaddfltflt(&v.u.cval->imag, &rv.u.cval->imag);
......
...@@ -64,6 +64,7 @@ var ( ...@@ -64,6 +64,7 @@ var (
c3 float64 = float64(Big) * Big // ERROR "overflow" c3 float64 = float64(Big) * Big // ERROR "overflow"
c4 = Big * Big // ERROR "overflow" c4 = Big * Big // ERROR "overflow"
c5 = Big / 0 // ERROR "division by zero" c5 = Big / 0 // ERROR "division by zero"
c6 = 1000 % 1e3 // ERROR "floating-point % operation"
) )
func f(int) func f(int)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment