diff options
Diffstat (limited to 'src/cmd/compile')
-rw-r--r-- | src/cmd/compile/internal/gc/const.go | 2 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/swt.go | 2 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/typecheck.go | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/gc/const.go b/src/cmd/compile/internal/gc/const.go index afcdb95443..c01820506d 100644 --- a/src/cmd/compile/internal/gc/const.go +++ b/src/cmd/compile/internal/gc/const.go @@ -1327,7 +1327,7 @@ func (n *Node) isGoConst() bool { } return true - case OCONV: + case OCONV, OCONVNOP: if okforconst[n.Type.Etype] && n.Left.isGoConst() { return true } diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go index b475e7adc3..a985626a02 100644 --- a/src/cmd/compile/internal/gc/swt.go +++ b/src/cmd/compile/internal/gc/swt.go @@ -679,7 +679,7 @@ func checkDupExprCases(exprname *Node, clauses []*Node) { seen := make(map[typeVal]*Node) for _, ncase := range clauses { for _, n := range ncase.List.Slice() { - if ct := consttype(n); ct == 0 || ct == CTBOOL { + if ct := consttype(n); ct == 0 || ct == CTBOOL || ct == CTNIL { continue } tv := typeVal{ diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index 069a38cbbb..cbca685415 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -1818,9 +1818,9 @@ func typecheck1(n *Node, top int) (res *Node) { switch n.Op { case OCONVNOP: - if n.Left.Op == OLITERAL { - n.Op = OCONV - setconst(n, n.Left.Val()) + if n.Left.Op == OLITERAL && n.isGoConst() { + n.Op = OCONV // set so n.Orig gets OCONV instead of OCONVNOP + setconst(n, n.Left.Val()) // convert n to OLITERAL with the given value } else if t.Etype == n.Type.Etype { switch t.Etype { case TFLOAT32, TFLOAT64, TCOMPLEX64, TCOMPLEX128: |