summaryrefslogtreecommitdiff
path: root/test/fixedbugs
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-01-27 15:43:52 -0800
committerKeith Randall <khr@google.com>2023-01-28 04:29:02 +0000
commit1e12c63aacce3749c4fb649477f9b44f74ebf550 (patch)
tree2fdf09cd341b3fdc8f60ae6deca07ee1dc405bb9 /test/fixedbugs
parentb15297fcd2921d26b11aedf915164b3b9b40b9aa (diff)
downloadgo-git-1e12c63aacce3749c4fb649477f9b44f74ebf550.tar.gz
cmd/compile: fix -m=2 output for recursive function with closures
ir.VisitFuncsBottomUp returns recursive==true for functions which call themselves. It also returns any closures inside that function. We don't want to report the closures as recursive, as they really aren't. Only the containing function is recursive. Fixes #54159 Change-Id: I3b4d6710a389ec1d6b250ba8a7065f2e985bdbe1 Reviewed-on: https://go-review.googlesource.com/c/go/+/463233 Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/fixedbugs')
-rw-r--r--test/fixedbugs/issue54159.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/fixedbugs/issue54159.go b/test/fixedbugs/issue54159.go
new file mode 100644
index 0000000000..8ef0e68483
--- /dev/null
+++ b/test/fixedbugs/issue54159.go
@@ -0,0 +1,22 @@
+// errorcheck -0 -m=2
+
+// Copyright 2023 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 run() { // ERROR "cannot inline run: recursive"
+ f := func() { // ERROR "can inline run.func1 with cost .* as:.*" "func literal does not escape"
+ g() // ERROR "inlining call to g"
+ }
+ f() // ERROR "inlining call to run.func1" "inlining call to g"
+ run()
+}
+
+func g() { // ERROR "can inline g with cost .* as:.*"
+}
+
+func main() { // ERROR "can inline main with cost .* as:.*"
+ run()
+}