]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix contrived line number errors
authorMatthew Dempsky <mdempsky@google.com>
Fri, 26 Feb 2016 06:10:48 +0000 (22:10 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 26 Feb 2016 21:25:43 +0000 (21:25 +0000)
commitaf558acc470dc1590788bbd695b0727e382cb74c
tree5d9d18c38f0899f5c47770ab7288d729e34bfc1b
parenta131a66e63d805db05bb320146815ee053a1c258
cmd/compile: fix contrived line number errors

If a general comment contains multiple newline characters, we can't
simply unread one and then re-lex it via the general whitespace lexing
phase, because then we'll reset lineno to the line before the "*/"
marker, rather than keeping it where we found the "/*" marker.

Also, for processing imports, call importfile before advancing the
lexer with p.next(), so that lineno reflects the line where we found
the import path, and not the token afterwards.

Fixes #14520.

Change-Id: I785a2d83d632280113d4b757de0d57c88ba2caf4
Reviewed-on: https://go-review.googlesource.com/19934
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/lex.go
src/cmd/compile/internal/gc/parser.go
test/fixedbugs/issue14520.go [new file with mode: 0644]