aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2022-10-08 12:32:06 +0700
committerHeschi Kreinick <heschi@google.com>2022-10-24 19:05:12 +0000
commit0618956b31e11072fcc21c8e9488a7a731482c0b (patch)
tree425eb9ddb8ff702d15b21037c21aedf6e83f97eb
parente73130cf45dbc8cf6e3074b4cda9674b18d82feb (diff)
downloadgo-0618956b31e11072fcc21c8e9488a7a731482c0b.tar.gz
go-0618956b31e11072fcc21c8e9488a7a731482c0b.zip
[release-branch.go1.19] cmd/compile: fix missing walk pass for static initialization slice
CL 403995 fixed static init of literal contains dynamic exprs, by ensuring their init are ordered properly. However, we still need to walk the generated init codes before appending to parent init. Otherwise, codes that requires desugaring will be unhandled, causing the compiler backend crashing. Fixes #56106 Change-Id: Ic25fd4017473f5412c8e960a91467797a234edfd Reviewed-on: https://go-review.googlesource.com/c/go/+/440455 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/441995 Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: David Chase <drchase@google.com>
-rw-r--r--src/cmd/compile/internal/walk/complit.go1
-rw-r--r--test/fixedbugs/issue56105.go11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/walk/complit.go b/src/cmd/compile/internal/walk/complit.go
index 595fe8538c..603c479a08 100644
--- a/src/cmd/compile/internal/walk/complit.go
+++ b/src/cmd/compile/internal/walk/complit.go
@@ -243,6 +243,7 @@ func fixedlit(ctxt initContext, kind initKind, n *ir.CompLitExpr, var_ ir.Node,
// confuses about variables lifetime. So making sure those expressions
// are ordered correctly here. See issue #52673.
orderBlock(&sinit, map[string][]*ir.Name{})
+ walkStmtList(sinit)
}
init.Append(sinit...)
continue
diff --git a/test/fixedbugs/issue56105.go b/test/fixedbugs/issue56105.go
new file mode 100644
index 0000000000..ecbe265807
--- /dev/null
+++ b/test/fixedbugs/issue56105.go
@@ -0,0 +1,11 @@
+// compile -d=libfuzzer
+
+// 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 p
+
+func f() {
+ _ = [...][]int{{}, {}, {}, {}, {}}
+}