]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove parser lineno hack for issue #13267
authorMatthew Dempsky <mdempsky@google.com>
Tue, 23 Feb 2016 23:29:19 +0000 (15:29 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 24 Feb 2016 00:19:46 +0000 (00:19 +0000)
After golang.org/cl/19652 removed the bizarre lexlineno{++,--}
statements for parsing canned imports, this hack for #13267 is no
longer necessary:

    $ echo -n 0 > /tmp/0.go
    $ go tool compile /tmp/0.go
    /tmp/0.go:1: syntax error: package statement must be first

Apparently setting lexlineno to 2 while parsing the canned imports
caused prevlineno and lineno to also be set to 2.  After we finished
parsing imports and restored lexlineno to 1, since "package" is the
first token in a source file, we'll have fixed lineno = 1, but
prevlineno was still set to 2.

Change-Id: Ibcc49fe3402264819b9abb53505631f7a0ad4a36
Reviewed-on: https://go-review.googlesource.com/19859
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/parser.go

index fbc5a5e1eb83c879b6f9b33a9488b75ec5fdc49b..61656845744b893a500c492ea4868a07df2d0d08 100644 (file)
@@ -280,13 +280,11 @@ func (p *parser) package_() {
                defer p.trace("package_")()
        }
 
-       if p.got(LPACKAGE) {
-               mkpackage(p.sym().Name)
-       } else {
-               prevlineno = lineno // see issue #13267
+       if !p.got(LPACKAGE) {
                p.syntax_error("package statement must be first")
                errorexit()
        }
+       mkpackage(p.sym().Name)
 }
 
 // ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .