aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-02-17 17:49:40 -0800
committerDmitri Shuralyov <dmitshur@golang.org>2021-03-01 18:01:46 +0000
commitddeae6b248e5130fe634047c3ca5964f5fa4e3dd (patch)
treeb083127b5ce2e163386a1aa669d2d411baa26e42 /test
parentb7e0eb49d8bb76ea0d98db53beef7209d9bd96d9 (diff)
downloadgo-ddeae6b248e5130fe634047c3ca5964f5fa4e3dd.tar.gz
go-ddeae6b248e5130fe634047c3ca5964f5fa4e3dd.zip
[release-branch.go1.16] cmd/compile: declare inlined result params early for empty returns
The code for delayed declaration of inlined result parameters only handles non-empty return statements. This is generally okay, because we already early declare if there are any (non-blank) named result parameters. But if a user writes a function with only blank result parameters and with exactly one return statement, which is empty, then they could end up hitting the dreaded "Value live at entry" ICE. This CL fixes the issue by ensuring we always early declare inlined result parameters if there are any empty return statements. Fixes #44358. Change-Id: I315f3853be436452883b1ce31da1bdffdf24d506 Reviewed-on: https://go-review.googlesource.com/c/go/+/293293 TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/296569
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue44355.dir/a.go7
-rw-r--r--test/fixedbugs/issue44355.dir/b.go9
-rw-r--r--test/fixedbugs/issue44355.go7
3 files changed, 23 insertions, 0 deletions
diff --git a/test/fixedbugs/issue44355.dir/a.go b/test/fixedbugs/issue44355.dir/a.go
new file mode 100644
index 0000000000..0f63c6fd98
--- /dev/null
+++ b/test/fixedbugs/issue44355.dir/a.go
@@ -0,0 +1,7 @@
+// 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 a
+
+func F() (_ *int) { return nil }
diff --git a/test/fixedbugs/issue44355.dir/b.go b/test/fixedbugs/issue44355.dir/b.go
new file mode 100644
index 0000000000..09d5bde887
--- /dev/null
+++ b/test/fixedbugs/issue44355.dir/b.go
@@ -0,0 +1,9 @@
+// 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 b
+
+import "./a"
+
+var _ = a.F()
diff --git a/test/fixedbugs/issue44355.go b/test/fixedbugs/issue44355.go
new file mode 100644
index 0000000000..d406838588
--- /dev/null
+++ b/test/fixedbugs/issue44355.go
@@ -0,0 +1,7 @@
+// compiledir
+
+// 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 ignored