]> Cypherpunks repositories - gostls13.git/commitdiff
gc: another shift bug
authorRuss Cox <rsc@golang.org>
Mon, 13 Dec 2010 18:42:51 +0000 (13:42 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 13 Dec 2010 18:42:51 +0000 (13:42 -0500)
Fixes #1316.

R=ken2
CC=golang-dev
https://golang.org/cl/3575042

src/cmd/gc/const.c
test/const3.go

index a3405e078c3941028ec8e295b087863ac3e9c0b1..5a7c5489428b9af80524910735dbdc4621b79025 100644 (file)
@@ -101,7 +101,7 @@ convlit1(Node **np, Type *t, int explicit)
                break;
        case OLSH:
        case ORSH:
-               convlit1(&n->left, t, explicit);
+               convlit1(&n->left, t, explicit && isideal(n->left->type));
                t = n->left->type;
                if(t != T && !isint[t->etype]) {
                        yyerror("invalid operation: %#N (shift of type %T)", n, t);
index dd5c88958d762250b78286e0267f78734a993d14..9bba6ced0b8bd109d02cfba5035302cc10475d3c 100644 (file)
@@ -26,4 +26,10 @@ func main() {
                println("type info didn't propagate in const: got", s)
                panic("fail")
        }
+       x := uint(5)
+       y := float64(uint64(1)<<x)      // used to fail to compile
+       if y != 32 {
+               println("wrong y", y)
+               panic("fail")
+       }
 }