aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Randall <khr@google.com>2019-01-22 13:49:47 -0800
committerKeith Randall <khr@golang.org>2019-01-22 22:06:11 +0000
commit1fb596143cd47145c8cee0c1c5ed5e871feeb2b1 (patch)
tree1f7efa777c793079cf2fe349b06359e761026a2f /src
parentef82ecd0f604f6323bcca6fc06ccd3ac94982c60 (diff)
downloadgo-1fb596143cd47145c8cee0c1c5ed5e871feeb2b1.tar.xz
cmd/compile: don't bother compiling functions named "_"
They can't be used, so we don't need code generated for them. We just need to report errors in their bodies. This is the minimal CL for 1.12. For 1.13, CL 158845 will remove a bunch of special cases sprinkled about the compiler to handle "_" functions, which should (after this CL) be unnecessary. Update #29870 Change-Id: Iaa1c194bd0017dffdce86589fe2d36726ee83c13 Reviewed-on: https://go-review.googlesource.com/c/158820 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/pgen.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/pgen.go b/src/cmd/compile/internal/gc/pgen.go
index 63e5860950..1dc4b53427 100644
--- a/src/cmd/compile/internal/gc/pgen.go
+++ b/src/cmd/compile/internal/gc/pgen.go
@@ -243,6 +243,14 @@ func compile(fn *Node) {
// From this point, there should be no uses of Curfn. Enforce that.
Curfn = nil
+ if fn.funcname() == "_" {
+ // We don't need to generate code for this function, just report errors in its body.
+ // At this point we've generated any errors needed.
+ // (Beyond here we generate only non-spec errors, like "stack frame too large".)
+ // See issue 29870.
+ return
+ }
+
// Set up the function's LSym early to avoid data races with the assemblers.
fn.Func.initLSym(true)