From c6e82e5808f4fb6da0fcc9754e29a220451a0dfd Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Mon, 25 Oct 2021 17:54:11 +0800 Subject: 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 Trust: Dan Scales Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall Reviewed-by: Dan Scales --- src/cmd/compile/internal/inline/inl.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/cmd/compile/internal/inline') diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index fb6cf53155..1ae6a58de0 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -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 - } - if m.Op() == ir.ORANGE { + 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 } + } switch m := m.(type) { -- cgit v1.3