mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: fix inlining labeled switch statements
CL 357649 fixes inlining labeled FOR/RANGE loops, we should do same translation for inlined SWITCH's label Fixes #49145 Change-Id: I9a6f365f57e974271a1eb279b38e81f9b5148788 Reviewed-on: https://go-review.googlesource.com/c/go/+/358315 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
parent
2c66cab8a7
commit
c6e82e5808
3 changed files with 43 additions and 7 deletions
|
|
@ -1285,18 +1285,24 @@ func (subst *inlsubst) node(n ir.Node) ir.Node {
|
|||
ir.EditChildren(m, subst.edit)
|
||||
|
||||
if subst.newclofn == nil {
|
||||
// Translate any label on FOR or RANGE loops
|
||||
if m.Op() == ir.OFOR {
|
||||
// Translate any label on FOR, RANGE loops or SWITCH
|
||||
switch m.Op() {
|
||||
case ir.OFOR:
|
||||
m := m.(*ir.ForStmt)
|
||||
m.Label = translateLabel(m.Label)
|
||||
return m
|
||||
|
||||
case ir.ORANGE:
|
||||
m := m.(*ir.RangeStmt)
|
||||
m.Label = translateLabel(m.Label)
|
||||
return m
|
||||
|
||||
case ir.OSWITCH:
|
||||
m := m.(*ir.SwitchStmt)
|
||||
m.Label = translateLabel(m.Label)
|
||||
return m
|
||||
}
|
||||
|
||||
if m.Op() == ir.ORANGE {
|
||||
m := m.(*ir.RangeStmt)
|
||||
m.Label = translateLabel(m.Label)
|
||||
return m
|
||||
}
|
||||
}
|
||||
|
||||
switch m := m.(type) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue