mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: detect duplicate importing earlier
Change-Id: I05ba944e189a884b727e40a9526d212612c3e923 Reviewed-on: https://go-review.googlesource.com/c/go/+/299770 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
parent
e8e425cb23
commit
b6df58bd1f
2 changed files with 4 additions and 9 deletions
|
|
@ -108,6 +108,9 @@ var inTypeCheckInl bool
|
||||||
// Lazy typechecking of imported bodies. For local functions, CanInline will set ->typecheck
|
// Lazy typechecking of imported bodies. For local functions, CanInline will set ->typecheck
|
||||||
// because they're a copy of an already checked body.
|
// because they're a copy of an already checked body.
|
||||||
func ImportedBody(fn *ir.Func) {
|
func ImportedBody(fn *ir.Func) {
|
||||||
|
if fn.Inl.Body != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
lno := ir.SetPos(fn.Nname)
|
lno := ir.SetPos(fn.Nname)
|
||||||
|
|
||||||
// When we load an inlined body, we need to allow OADDR
|
// When we load an inlined body, we need to allow OADDR
|
||||||
|
|
@ -151,14 +154,6 @@ func ImportedBody(fn *ir.Func) {
|
||||||
inTypeCheckInl = false
|
inTypeCheckInl = false
|
||||||
ir.CurFunc = savefn
|
ir.CurFunc = savefn
|
||||||
|
|
||||||
// During ImportBody (which imports fn.Func.Inl.Body),
|
|
||||||
// declarations are added to fn.Func.Dcl by funcBody(). Move them
|
|
||||||
// to fn.Func.Inl.Dcl for consistency with how local functions
|
|
||||||
// behave. (Append because ImportedBody may be called multiple
|
|
||||||
// times on same fn.)
|
|
||||||
fn.Inl.Dcl = append(fn.Inl.Dcl, fn.Dcl...)
|
|
||||||
fn.Dcl = nil
|
|
||||||
|
|
||||||
base.Pos = lno
|
base.Pos = lno
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ func expandDecl(n ir.Node) ir.Node {
|
||||||
|
|
||||||
func ImportBody(fn *ir.Func) {
|
func ImportBody(fn *ir.Func) {
|
||||||
if fn.Inl.Body != nil {
|
if fn.Inl.Body != nil {
|
||||||
return
|
base.Fatalf("%v already has inline body", fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
r := importReaderFor(fn.Nname.Sym(), inlineImporter)
|
r := importReaderFor(fn.Nname.Sym(), inlineImporter)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue