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

cmd/compile: give informative error instead of "stupid shift"

Fixes #13940.

Change-Id: I00fe377c949e5be4cbc035f6ca18e547e326bfba
Reviewed-on: https://go-review.googlesource.com/19856
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Robert Griesemer 2016-02-23 13:35:12 -08:00
parent ef3c45adfc
commit d1cc7f70cd
2 changed files with 7 additions and 3 deletions

View File

@ -217,7 +217,11 @@ func mplshfixfix(a, b *Mpint) {
s := Mpgetfix(b)
if s < 0 || s >= Mpprec {
Yyerror("stupid shift: %d", s)
msg := "shift count too large"
if s < 0 {
msg = "invalid negative shift count"
}
Yyerror("%s: %d", msg, s)
Mpmovecfix(a, 0)
return
}
@ -236,7 +240,7 @@ func mprshfixfix(a, b *Mpint) {
s := Mpgetfix(b)
if s < 0 {
Yyerror("stupid shift: %d", s)
Yyerror("invalid negative shift count: %d", s)
if a.Val.Sign() < 0 {
Mpmovecfix(a, -1)
} else {

View File

@ -6,6 +6,6 @@
package main
func f() {
v := 1 << 1025; // ERROR "overflow|stupid shift"
v := 1 << 1025; // ERROR "overflow|shift count too large"
_ = v
}