mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: change irgen to generate exprs/stmts after decls processed
This CL changes irgen to wait until all top-level declarations have been processed before constructing any expressions or statements that reference them. This is the same approach that typecheck used. Mechanically, it splits varDecl and funcDecl (the two top-level declarations that can generate/contain code) into a part that runs immediately for constructing the ir.ONAME, and then a separate task that runs later to handle the code. It also adds an exprStmtOK flag to indicate when it's actually safe to start constructing (non-trivial) expressions and statements. Fixes #47928. Change-Id: I51942af6823aa561d341e2ffc1142948da025fa2 Reviewed-on: https://go-review.googlesource.com/c/go/+/344649 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
parent
daa55b21d1
commit
4a9f0cec29
5 changed files with 121 additions and 59 deletions
|
|
@ -50,6 +50,8 @@ func (g *irgen) expr(expr syntax.Expr) ir.Node {
|
|||
base.FatalfAt(g.pos(expr), "unrecognized type-checker result")
|
||||
}
|
||||
|
||||
base.Assert(g.exprStmtOK)
|
||||
|
||||
// The gc backend expects all expressions to have a concrete type, and
|
||||
// types2 mostly satisfies this expectation already. But there are a few
|
||||
// cases where the Go spec doesn't require converting to concrete type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue