]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: give informative error instead of "stupid shift"
authorRobert Griesemer <gri@golang.org>
Tue, 23 Feb 2016 21:35:12 +0000 (13:35 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 23 Feb 2016 22:31:35 +0000 (22:31 +0000)
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>

src/cmd/compile/internal/gc/mparith2.go
test/fixedbugs/bug108.go

index 28c3a00825e9b4773065e44823fda7490889aa40..67faf294796f2e48294033d8d1f94eb173f6d9f7 100644 (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 {
index 9f2a27ebd97431e0d3c9b42499ab896473f2875d..cfec4c9f1f47138747714a37081c5b928425dcee 100644 (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
 }