1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:04:39 -07:00

gc: fix error for floating-point constant %

R=ken2
CC=golang-dev
https://golang.org/cl/5674108
This commit is contained in:
Russ Cox 2012-02-19 00:12:31 -05:00
parent 03f2289f7e
commit 83feedf7bf
2 changed files with 36 additions and 27 deletions

View File

@ -660,6 +660,14 @@ evconst(Node *n)
}
mpdivfltflt(v.u.fval, rv.u.fval);
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):
mpaddfltflt(&v.u.cval->real, &rv.u.cval->real);
mpaddfltflt(&v.u.cval->imag, &rv.u.cval->imag);

View File

@ -64,6 +64,7 @@ var (
c3 float64 = float64(Big) * Big // ERROR "overflow"
c4 = Big * Big // ERROR "overflow"
c5 = Big / 0 // ERROR "division by zero"
c6 = 1000 % 1e3 // ERROR "floating-point % operation"
)
func f(int)