cmd/compile: fix compilation crash with several blank labels

Fixes #52278

Change-Id: Ibf67c7b019feec277d316e04d93b458efea133fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/399574
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
nimelehin 2022-04-11 19:54:30 +03:00 committed by Gopher Robot
parent ec5e5dba6f
commit be0262a127
3 changed files with 18 additions and 0 deletions

View File

@ -210,6 +210,9 @@ func (b *batch) walkFunc(fn *ir.Func) {
switch n.Op() {
case ir.OLABEL:
n := n.(*ir.LabelStmt)
if n.Label.IsBlank() {
break
}
if e.labels == nil {
e.labels = make(map[*types.Sym]labelState)
}

View File

@ -50,6 +50,9 @@ func (e *escape) stmt(n ir.Node) {
case ir.OLABEL:
n := n.(*ir.LabelStmt)
if n.Label.IsBlank() {
break
}
switch e.labels[n.Label] {
case nonlooping:
if base.Flag.LowerM > 2 {

View File

@ -0,0 +1,12 @@
// compile
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func main() {
_:
_:
}