aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2018-06-21 15:35:32 -0700
committerMatthew Dempsky <mdempsky@google.com>2018-06-21 23:57:55 +0000
commit011ea87921cb37dc8e4147d99c22234f875d2651 (patch)
treea5d3cb7cd83dc166a56817d3b9ea8297f0727d66
parent6c8100270cd1254fef21b48fa3f4e77fc9aab69d (diff)
downloadgo-011ea87921cb37dc8e4147d99c22234f875d2651.tar.gz
go-011ea87921cb37dc8e4147d99c22234f875d2651.zip
cmd/compile: fix recursive inimport handling
expandDecl can be called recursively, so it's not an appropriate place to clean inimport. Instead, move this up to resolve, along with an appropriate recursion check. Passes toolstash-check. Change-Id: I138d37b057dcc6525c780b4b3fbaa5e97f99655b Reviewed-on: https://go-review.googlesource.com/120455 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
-rw-r--r--src/cmd/compile/internal/gc/iimport.go2
-rw-r--r--src/cmd/compile/internal/gc/typecheck.go5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/gc/iimport.go b/src/cmd/compile/internal/gc/iimport.go
index d158899aaa..54c5d8dc2f 100644
--- a/src/cmd/compile/internal/gc/iimport.go
+++ b/src/cmd/compile/internal/gc/iimport.go
@@ -46,9 +46,7 @@ func expandDecl(n *Node) {
return
}
- inimport = true
r.doDecl(n)
- inimport = false
}
func expandInline(fn *Node) {
diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go
index 8f0d6050c3..1b68e057fc 100644
--- a/src/cmd/compile/internal/gc/typecheck.go
+++ b/src/cmd/compile/internal/gc/typecheck.go
@@ -37,7 +37,12 @@ func resolve(n *Node) *Node {
}
if n.Sym.Pkg != localpkg {
+ if inimport {
+ Fatalf("recursive inimport")
+ }
+ inimport = true
expandDecl(n)
+ inimport = false
return n
}