mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: fix line number in an error message
Fixes #6563. R=golang-dev, iant CC=golang-dev https://golang.org/cl/14870046
This commit is contained in:
parent
06ad3b2de1
commit
dbe2eacf04
4 changed files with 54 additions and 15 deletions
|
|
@ -654,7 +654,7 @@ func (p *Package) rewriteRef(f *File) {
|
|||
// Okay - might be new(T)
|
||||
expr = r.Name.Type.Go
|
||||
} else if r.Name.Kind == "var" {
|
||||
expr = &ast.StarExpr{X: expr}
|
||||
expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr}
|
||||
}
|
||||
|
||||
case "type":
|
||||
|
|
@ -683,6 +683,16 @@ func (p *Package) rewriteRef(f *File) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy position information from old expr into new expr,
|
||||
// in case expression being replaced is first on line.
|
||||
// See golang.org/issue/6563.
|
||||
pos := (*r.Expr).Pos()
|
||||
switch x := expr.(type) {
|
||||
case *ast.Ident:
|
||||
expr = &ast.Ident{NamePos: pos, Name: x.Name}
|
||||
}
|
||||
|
||||
*r.Expr = expr
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue