aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/ssa/expand_calls.go2
-rw-r--r--test/fixedbugs/issue49249.go55
-rw-r--r--test/fixedbugs/issue49378.go25
3 files changed, 82 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go
index 7e973ab2059..0c4a7fba4d0 100644
--- a/src/cmd/compile/internal/ssa/expand_calls.go
+++ b/src/cmd/compile/internal/ssa/expand_calls.go
@@ -952,6 +952,7 @@ func (x *expandState) storeArgOrLoad(pos src.XPos, b *Block, source, mem *Value,
return x.storeArgOrLoad(pos, b, source, mem, t, storeOffset, loadRegOffset, storeRc)
}
eltRO := x.regWidth(elt)
+ source.Type = t
for i := int64(0); i < t.NumElem(); i++ {
sel := source.Block.NewValue1I(pos, OpArraySelect, elt, i, source)
mem = x.storeArgOrLoad(pos, b, sel, mem, elt, storeOffset+i*elt.Width, loadRegOffset, storeRc.at(t, 0))
@@ -985,6 +986,7 @@ func (x *expandState) storeArgOrLoad(pos src.XPos, b *Block, source, mem *Value,
return x.storeArgOrLoad(pos, b, source, mem, t, storeOffset, loadRegOffset, storeRc)
}
+ source.Type = t
for i := 0; i < t.NumFields(); i++ {
fld := t.Field(i)
sel := source.Block.NewValue1I(pos, OpStructSelect, fld.Type, int64(i), source)
diff --git a/test/fixedbugs/issue49249.go b/test/fixedbugs/issue49249.go
new file mode 100644
index 00000000000..f152a5a7012
--- /dev/null
+++ b/test/fixedbugs/issue49249.go
@@ -0,0 +1,55 @@
+// compile -l
+
+// Copyright 2021 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 {
+ var a, b struct {
+ s struct {
+ s struct {
+ byte
+ float32
+ }
+ }
+ }
+ _ = a
+
+ return func() int {
+ return func() int {
+ a = struct {
+ s struct {
+ s struct {
+ byte
+ float32
+ }
+ }
+ }{b.s}
+ return 0
+ }()
+ }()
+}
+
+func g() int {
+ var a, b struct {
+ s [1][1]struct {
+ byte
+ float32
+ }
+ }
+ _ = a
+
+ return func() int {
+ return func() int {
+ a = struct {
+ s [1][1]struct {
+ byte
+ float32
+ }
+ }{b.s}
+ return 0
+ }()
+ }()
+}
diff --git a/test/fixedbugs/issue49378.go b/test/fixedbugs/issue49378.go
new file mode 100644
index 00000000000..70f466c929f
--- /dev/null
+++ b/test/fixedbugs/issue49378.go
@@ -0,0 +1,25 @@
+// compile
+
+// Copyright 2021 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(i int) {
+ var s1 struct {
+ s struct{ s struct{ i int } }
+ }
+ var s2, s3 struct {
+ a struct{ i int }
+ b int
+ }
+ func() {
+ i = 1 + 2*i + s3.a.i + func() int {
+ s2.a, s2.b = s3.a, s3.b
+ return 0
+ }() + func(*int) int {
+ return s1.s.s.i
+ }(new(int))
+ }()
+}