mirror of https://github.com/golang/go.git
cmd/compile: fix panic with nested dead hidden closures
CL 342350 fixed deadcode panic with dead hidden closures. However, a closure may contains nested dead hidden closures, so we need to mark them dead as well. Fixes #51839 Change-Id: Ib54581adfc1bdea60e74d733cd30fd8e783da983 Reviewed-on: https://go-review.googlesource.com/c/go/+/394079 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
627d6d6d55
commit
129a2fcf6c
|
|
@ -163,4 +163,5 @@ func markHiddenClosureDead(n ir.Node) {
|
||||||
if clo.Func.IsHiddenClosure() {
|
if clo.Func.IsHiddenClosure() {
|
||||||
clo.Func.SetIsDeadcodeClosure(true)
|
clo.Func.SetIsDeadcodeClosure(true)
|
||||||
}
|
}
|
||||||
|
ir.VisitList(clo.Func.Body, markHiddenClosureDead)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
// 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() {
|
||||||
|
testRecover()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRecover() {
|
||||||
|
if false {
|
||||||
|
func() {
|
||||||
|
defer func() {
|
||||||
|
_ = recover()
|
||||||
|
}()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue