]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/syntax: don't record semi position if there's none
authorRobert Griesemer <gri@golang.org>
Thu, 11 Jan 2018 01:14:20 +0000 (17:14 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 11 Jan 2018 01:30:49 +0000 (01:30 +0000)
Fixes #23406.

Change-Id: Ief04e20357c9ca03a5e496f1742428394c8ee658
Reviewed-on: https://go-review.googlesource.com/87317
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/syntax/parser.go

index ff3e769864e8f3b74a19c4dbb5d40aed7cda4b9b..c8dfc967e69b3892db21342716d0a9e1a1b7b933 100644 (file)
@@ -1768,9 +1768,13 @@ func (p *parser) header(keyword token) (init SimpleStmt, cond Expr, post SimpleS
                lit string // valid if pos.IsKnown()
        }
        if p.tok != _Lbrace {
-               semi.pos = p.pos()
-               semi.lit = p.lit
-               p.want(_Semi)
+               if p.tok == _Semi {
+                       semi.pos = p.pos()
+                       semi.lit = p.lit
+                       p.next()
+               } else {
+                       p.want(_Semi)
+               }
                if keyword == _For {
                        if p.tok != _Semi {
                                if p.tok == _Lbrace {