Commit d1cc7f70 authored by Robert Griesemer's avatar Robert Griesemer

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

Fixes #13940.

Change-Id: I00fe377c949e5be4cbc035f6ca18e547e326bfba
Reviewed-on: https://go-review.googlesource.com/19856Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ef3c45ad
......@@ -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 {
......
......@@ -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
}
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