aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/const.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/gc/const.go')
-rw-r--r--src/cmd/compile/internal/gc/const.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/gc/const.go b/src/cmd/compile/internal/gc/const.go
index 9eb4983606..5095e5ebd9 100644
--- a/src/cmd/compile/internal/gc/const.go
+++ b/src/cmd/compile/internal/gc/const.go
@@ -1279,20 +1279,28 @@ func defaultlit(np **Node, t *Type) {
return
num:
+ // Note: n.Val().Ctype() can be CTxxx (not a constant) here
+ // in the case of an untyped non-constant value, like 1<<i.
+ v1 := n.Val()
if t != nil {
if Isint[t.Etype] {
t1 = t
- n.SetVal(toint(n.Val()))
+ v1 = toint(n.Val())
} else if Isfloat[t.Etype] {
t1 = t
- n.SetVal(toflt(n.Val()))
+ v1 = toflt(n.Val())
} else if Iscomplex[t.Etype] {
t1 = t
- n.SetVal(tocplx(n.Val()))
+ v1 = tocplx(n.Val())
+ }
+ if n.Val().Ctype() != CTxxx {
+ n.SetVal(v1)
}
}
- overflow(n.Val(), t1)
+ if n.Val().Ctype() != CTxxx {
+ overflow(n.Val(), t1)
+ }
Convlit(np, t1)
lineno = int32(lno)
return