From: Michael Fraenkel Date: Sun, 25 Feb 2018 19:26:24 +0000 (-0500) Subject: cmd/compile: convert untyped bool during walkCases X-Git-Tag: go1.11beta1~1420 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a375a6b3638f99c33dfc95a398a0e6fd8b5700df;p=gostls13.git cmd/compile: convert untyped bool during walkCases Updates #23834. Change-Id: I1789525a992d37aae9e9b69c1e9d91437d3d0d3b Reviewed-on: https://go-review.googlesource.com/97001 Run-TryBot: Matthew Dempsky Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go index 8d425506d3..f4be8a7f26 100644 --- a/src/cmd/compile/internal/gc/swt.go +++ b/src/cmd/compile/internal/gc/swt.go @@ -315,16 +315,19 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node { high := nod(OLE, s.exprname, rng[1]) a.Left = nod(OANDAND, low, high) a.Left = typecheck(a.Left, Erv) + a.Left = defaultlit(a.Left, nil) a.Left = walkexpr(a.Left, nil) // give walk the opportunity to optimize the range check } else if (s.kind != switchKindTrue && s.kind != switchKindFalse) || assignop(n.Left.Type, s.exprname.Type, nil) == OCONVIFACE || assignop(s.exprname.Type, n.Left.Type, nil) == OCONVIFACE { a.Left = nod(OEQ, s.exprname, n.Left) // if name == val a.Left = typecheck(a.Left, Erv) + a.Left = defaultlit(a.Left, nil) } else if s.kind == switchKindTrue { a.Left = n.Left // if val } else { // s.kind == switchKindFalse a.Left = nod(ONOT, n.Left, nil) // if !val a.Left = typecheck(a.Left, Erv) + a.Left = defaultlit(a.Left, nil) } a.Nbody.Set1(n.Right) // goto l @@ -354,6 +357,7 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node { a.Left = le } a.Left = typecheck(a.Left, Erv) + a.Left = defaultlit(a.Left, nil) a.Nbody.Set1(s.walkCases(cc[:half])) a.Rlist.Set1(s.walkCases(cc[half:])) return a