diff options
| author | griesemer <gri@golang.org> | 2017-11-10 11:38:51 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2017-11-13 16:47:41 +0000 |
| commit | ca2a886cbade477e2c7cf09cdac604b757fb70a9 (patch) | |
| tree | a53caa12f75272cad04d04bd5ea1ffd3dea576ef /src/cmd/compile/internal/syntax/parser.go | |
| parent | 2c00dea18b4a62fbf0bc11c85e4d9b91a314381f (diff) | |
| download | go-ca2a886cbade477e2c7cf09cdac604b757fb70a9.tar.xz | |
cmd/compile: record original and absolute file names for line directives
Also, with this change, error locations don't print absolute positions
in [] brackets following positions relative to line directives. To get
the absolute positions as well, specify the -L flag.
Fixes #22660.
Change-Id: I9ecfa254f053defba9c802222874155fa12fee2c
Reviewed-on: https://go-review.googlesource.com/77090
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/syntax/parser.go')
| -rw-r--r-- | src/cmd/compile/internal/syntax/parser.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index 7047266a70..ff3e769864 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -80,11 +80,12 @@ func (p *parser) updateBase(line, col uint, text string) { p.error_at(p.pos_at(line, col+uint(i+1)), "invalid line number: "+nstr) return } - absFile := text[:i] + filename := text[:i] + absFilename := filename if p.fileh != nil { - absFile = p.fileh(absFile) + absFilename = p.fileh(filename) } - p.base = src.NewLinePragmaBase(src.MakePos(p.base.Pos().Base(), line, col), absFile, uint(n)) + p.base = src.NewLinePragmaBase(src.MakePos(p.base.Pos().Base(), line, col), filename, absFilename, uint(n)) } func (p *parser) got(tok token) bool { |
