aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/reader.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2023-01-25 17:08:16 -0500
committerDavid Chase <drchase@google.com>2023-03-06 18:34:53 +0000
commit5a7793b7b81e1069cc830a14997ede3730295175 (patch)
treeadc5bd6174deab654d26ddc0eec4025bb65de4bf /src/cmd/compile/internal/noder/reader.go
parentc20d95916357acf141159d4efc8894bfc14a2cd6 (diff)
downloadgo-5a7793b7b81e1069cc830a14997ede3730295175.tar.xz
cmd/compile: add flag to FOR/RANGE to preserve loop semantics across inlines
This modifies the loopvar change to be tied to the package if it is specified that way, and preserves the change across inlining. Down the road, this will be triggered (and flow correctly) if the changed semantics are tied to Go version specified in go.mod (or rather, for the compiler, by the specified version for compilation). Includes tests. Change-Id: If54e8b6dd23273b86be5ba47838c90d38af9bd1a Reviewed-on: https://go-review.googlesource.com/c/go/+/463595 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/reader.go')
-rw-r--r--src/cmd/compile/internal/noder/reader.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index 64173312ac..6098c92ac9 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -1857,7 +1857,7 @@ func (r *reader) forStmt(label *types.Sym) ir.Node {
if r.Bool() {
pos := r.pos()
- rang := ir.NewRangeStmt(pos, nil, nil, nil, nil)
+ rang := ir.NewRangeStmt(pos, nil, nil, nil, nil, false)
rang.Label = label
names, lhs := r.assignList()
@@ -1881,6 +1881,7 @@ func (r *reader) forStmt(label *types.Sym) ir.Node {
}
rang.Body = r.blockStmt()
+ rang.DistinctVars = r.Bool()
r.closeAnotherScope()
return rang
@@ -1891,9 +1892,10 @@ func (r *reader) forStmt(label *types.Sym) ir.Node {
cond := r.optExpr()
post := r.stmt()
body := r.blockStmt()
+ dv := r.Bool()
r.closeAnotherScope()
- stmt := ir.NewForStmt(pos, init, cond, post, body)
+ stmt := ir.NewForStmt(pos, init, cond, post, body, dv)
stmt.Label = label
return stmt
}