From 24dc27a3c084b901ee456637541ea818495888b0 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sun, 24 Jul 2022 09:48:56 -0700 Subject: [PATCH] cmd/compile: fix blank label code When checkEnabled is forced true, the 52278 test fails. Be a bit more careful about processing blank labels. Update #52278 Change-Id: I48aa89e2c9e3715d8efe599bc4363b5b5879d8a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/419318 Run-TryBot: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Reviewed-by: David Chase --- src/cmd/compile/internal/ssagen/ssa.go | 4 ++++ test/fixedbugs/issue52278.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index a7778d37fb3..2ee027092e9 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -1496,6 +1496,10 @@ func (s *state) stmt(n ir.Node) { case ir.OLABEL: n := n.(*ir.LabelStmt) sym := n.Label + if sym.IsBlank() { + // Nothing to do because the label isn't targetable. See issue 52278. + break + } lab := s.label(sym) // The label might already have a target block via a goto. diff --git a/test/fixedbugs/issue52278.go b/test/fixedbugs/issue52278.go index 56169e68714..147b6530373 100644 --- a/test/fixedbugs/issue52278.go +++ b/test/fixedbugs/issue52278.go @@ -1,4 +1,4 @@ -// compile +// compile -d=ssa/check/on // Copyright 2022 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style