aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2018-04-08 09:37:44 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2018-04-11 23:46:30 +0000
commit2dfb423e6e84b64acb0dc741cba5b1fa5fe03c64 (patch)
treec599ca91123abc7c240833a15f3ca02327f70bd3
parent8f6ae3379615c6e9dcf47bafc74710a1346a932e (diff)
downloadgo-2dfb423e6e84b64acb0dc741cba5b1fa5fe03c64.tar.xz
cmd/compile: loop to ensure all autogenerated functions are compiled
I was wrong. There was a need to loop here. Fixes #24761 Change-Id: If13b3ab72febde930bdaebdddd1c05e0d0446020 Reviewed-on: https://go-review.googlesource.com/105615 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
-rw-r--r--src/cmd/compile/internal/gc/obj.go19
-rw-r--r--test/fixedbugs/issue24761.dir/a.go15
-rw-r--r--test/fixedbugs/issue24761.dir/b.go11
-rw-r--r--test/fixedbugs/issue24761.go7
4 files changed, 43 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go
index bf2a621ebe..aec6fe5397 100644
--- a/src/cmd/compile/internal/gc/obj.go
+++ b/src/cmd/compile/internal/gc/obj.go
@@ -144,16 +144,17 @@ func dumpLinkerObj(bout *bio.Writer) {
dumpimportstrings()
dumpbasictypes()
- // The first call to dumpsignats can generate functions,
+ // Calls to dumpsignats can generate functions,
// like method wrappers and hash and equality routines.
- compileFunctions()
-
- // Process any new signats added during compilation.
- // No need to loop here; signats from compiling the generated
- // functions should not themselves generate new functions.
- // If they do, we'll know about it; the sanity check of
- // len(compilequeue) in gc.Main will fail.
- dumpsignats()
+ // Compile any generated functions, process any new resulting types, repeat.
+ // This can't loop forever, because there is no way to generate an infinite
+ // number of types in a finite amount of code.
+ // In the typical case, we loop 0 or 1 times.
+ // It was not until issue 24761 that we found any code that required a loop at all.
+ for len(compilequeue) > 0 {
+ compileFunctions()
+ dumpsignats()
+ }
// Dump extra globals.
tmp := externdcl
diff --git a/test/fixedbugs/issue24761.dir/a.go b/test/fixedbugs/issue24761.dir/a.go
new file mode 100644
index 0000000000..1aa2317bd5
--- /dev/null
+++ b/test/fixedbugs/issue24761.dir/a.go
@@ -0,0 +1,15 @@
+// Copyright 2018 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
+
+type T2 struct{}
+
+func (t *T2) M2(a, b float64) {
+ variadic(a, b)
+}
+
+func variadic(points ...float64) {
+ println(points)
+}
diff --git a/test/fixedbugs/issue24761.dir/b.go b/test/fixedbugs/issue24761.dir/b.go
new file mode 100644
index 0000000000..dd3d543a0f
--- /dev/null
+++ b/test/fixedbugs/issue24761.dir/b.go
@@ -0,0 +1,11 @@
+// Copyright 2018 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"
+
+type T1 struct {
+ *a.T2
+}
diff --git a/test/fixedbugs/issue24761.go b/test/fixedbugs/issue24761.go
new file mode 100644
index 0000000000..4b97663c3c
--- /dev/null
+++ b/test/fixedbugs/issue24761.go
@@ -0,0 +1,7 @@
+// compiledir -c=4
+
+// Copyright 2018 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