Commit 7afd58d4 authored by Peter Waller's avatar Peter Waller Committed by Daniel Martí

cmd/compile/internal/ssa: set OFOR bBody.Pos to AST Pos

Assign SSA OFOR's bBody.Pos to AST (*Node).Pos as it is created.

An empty for loop has no other information which may be used to give
correct position information in the resulting executable. Such a for
loop may compile to a single `JMP *self` and it is important that the
location of this is in the right place.

Fixes #30167.

Change-Id: Iec44f0281c462c33fac6b7b8ccfc2ef37434c247
Reviewed-on: https://go-review.googlesource.com/c/go/+/163019
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDavid Chase <drchase@google.com>
parent 27cce773
...@@ -1077,6 +1077,9 @@ func (s *state) stmt(n *Node) { ...@@ -1077,6 +1077,9 @@ func (s *state) stmt(n *Node) {
bIncr := s.f.NewBlock(ssa.BlockPlain) bIncr := s.f.NewBlock(ssa.BlockPlain)
bEnd := s.f.NewBlock(ssa.BlockPlain) bEnd := s.f.NewBlock(ssa.BlockPlain)
// ensure empty for loops have correct position; issue #30167
bBody.Pos = n.Pos
// first, jump to condition test (OFOR) or body (OFORUNTIL) // first, jump to condition test (OFOR) or body (OFORUNTIL)
b := s.endBlock() b := s.endBlock()
if n.Op == OFOR { if n.Op == OFOR {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment