Skip to content

Commit 603f9fe

Browse files
committed
gc: another shift bug
Fixes golang#1316. R=ken2 CC=golang-dev https://golang.org/cl/3575042
1 parent 9da7361 commit 603f9fe

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/cmd/gc/const.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ convlit1(Node **np, Type *t, int explicit)
101101
break;
102102
case OLSH:
103103
case ORSH:
104-
convlit1(&n->left, t, explicit);
104+
convlit1(&n->left, t, explicit && isideal(n->left->type));
105105
t = n->left->type;
106106
if(t != T && !isint[t->etype]) {
107107
yyerror("invalid operation: %#N (shift of type %T)", n, t);

test/const3.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ func main() {
2626
println("type info didn't propagate in const: got", s)
2727
panic("fail")
2828
}
29+
x := uint(5)
30+
y := float64(uint64(1)<<x) // used to fail to compile
31+
if y != 32 {
32+
println("wrong y", y)
33+
panic("fail")
34+
}
2935
}

0 commit comments

Comments
 (0)