mirror of https://github.com/golang/go.git
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:
parent
ef3c45adfc
commit
d1cc7f70cd
|
|
@ -217,7 +217,11 @@ func mplshfixfix(a, b *Mpint) {
|
||||||
|
|
||||||
s := Mpgetfix(b)
|
s := Mpgetfix(b)
|
||||||
if s < 0 || s >= Mpprec {
|
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)
|
Mpmovecfix(a, 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -236,7 +240,7 @@ func mprshfixfix(a, b *Mpint) {
|
||||||
|
|
||||||
s := Mpgetfix(b)
|
s := Mpgetfix(b)
|
||||||
if s < 0 {
|
if s < 0 {
|
||||||
Yyerror("stupid shift: %d", s)
|
Yyerror("invalid negative shift count: %d", s)
|
||||||
if a.Val.Sign() < 0 {
|
if a.Val.Sign() < 0 {
|
||||||
Mpmovecfix(a, -1)
|
Mpmovecfix(a, -1)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
func f() {
|
func f() {
|
||||||
v := 1 << 1025; // ERROR "overflow|stupid shift"
|
v := 1 << 1025; // ERROR "overflow|shift count too large"
|
||||||
_ = v
|
_ = v
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue