[dev.inline] cmd/compile/internal/syntax: add tests for //line directives

Change-Id: I77dc73bfe79e43bbadf85d7eb3c5f8990ec72023
Reviewed-on: https://go-review.googlesource.com/34248
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2016-12-09 14:28:49 -08:00
parent f3b56de4d2
commit a0c5405c18
3 changed files with 46 additions and 11 deletions

View file

@ -47,7 +47,7 @@ func (p *parser) init(filename string, src io.Reader, errh ErrorHandler, pragh P
},
func(line, col uint, text string) {
if strings.HasPrefix(text, "line ") {
p.updateBase(line, col, text[5:])
p.updateBase(line, col+5, text[5:])
}
if pragh != nil {
p.pragma |= pragh(p.pos_at(line, col), text)
@ -67,7 +67,7 @@ func (p *parser) updateBase(line, col uint, text string) {
// Want to use LastIndexByte below but it's not defined in Go1.4 and bootstrap fails.
i := strings.LastIndex(text, ":") // look from right (Windows filenames may contain ':')
if i < 0 {
return
return // ignore (not a line directive)
}
nstr := text[i+1:]
n, err := strconv.Atoi(nstr)