mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
cmd/compile: fixing writebarrier.go for -G=3
This is caused by some nodes didn't carry the real line number. Noder1 wraps these node with ir.ParenExpr. To fix this issue, wraps this node like what noder1 does. Change-Id: I212cad09b93b8bf1a7adfad416d229d15711918a Reviewed-on: https://go-review.googlesource.com/c/go/+/349769 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Keith Randall <khr@golang.org>
This commit is contained in:
parent
bcdc61d830
commit
d09e09bc61
5 changed files with 14 additions and 7 deletions
|
@ -390,9 +390,10 @@ func (g *irgen) compLit(typ types2.Type, lit *syntax.CompositeLit) ir.Node {
|
|||
} else {
|
||||
key = g.expr(elem.Key)
|
||||
}
|
||||
exprs[i] = ir.NewKeyExpr(g.pos(elem), key, g.expr(elem.Value))
|
||||
value := wrapname(g.pos(elem.Value), g.expr(elem.Value))
|
||||
exprs[i] = ir.NewKeyExpr(g.pos(elem), key, value)
|
||||
default:
|
||||
exprs[i] = g.expr(elem)
|
||||
exprs[i] = wrapname(g.pos(elem), g.expr(elem))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1537,7 +1537,7 @@ func (p *noder) mkname(name *syntax.Name) ir.Node {
|
|||
return mkname(p.name(name))
|
||||
}
|
||||
|
||||
func (p *noder) wrapname(n syntax.Node, x ir.Node) ir.Node {
|
||||
func wrapname(pos src.XPos, x ir.Node) ir.Node {
|
||||
// These nodes do not carry line numbers.
|
||||
// Introduce a wrapper node to give them the correct line.
|
||||
switch x.Op() {
|
||||
|
@ -1547,13 +1547,17 @@ func (p *noder) wrapname(n syntax.Node, x ir.Node) ir.Node {
|
|||
}
|
||||
fallthrough
|
||||
case ir.ONAME, ir.ONONAME, ir.OPACK:
|
||||
p := ir.NewParenExpr(p.pos(n), x)
|
||||
p := ir.NewParenExpr(pos, x)
|
||||
p.SetImplicit(true)
|
||||
return p
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
func (p *noder) wrapname(n syntax.Node, x ir.Node) ir.Node {
|
||||
return wrapname(p.pos(n), x)
|
||||
}
|
||||
|
||||
func (p *noder) setlineno(n syntax.Node) {
|
||||
if n != nil {
|
||||
base.Pos = p.pos(n)
|
||||
|
|
|
@ -37,7 +37,7 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
|
|||
case *syntax.BlockStmt:
|
||||
return ir.NewBlockStmt(g.pos(stmt), g.blockStmt(stmt))
|
||||
case *syntax.ExprStmt:
|
||||
return g.expr(stmt.X)
|
||||
return wrapname(g.pos(stmt.X), g.expr(stmt.X))
|
||||
case *syntax.SendStmt:
|
||||
n := ir.NewSendStmt(g.pos(stmt), g.expr(stmt.Chan), g.expr(stmt.Value))
|
||||
if n.Chan.Type().HasTParam() || n.Value.Type().HasTParam() {
|
||||
|
|
|
@ -404,6 +404,10 @@ func assignconvfn(n ir.Node, t *types.Type) ir.Node {
|
|||
return n
|
||||
}
|
||||
|
||||
if n.Op() == ir.OPAREN {
|
||||
n = n.(*ir.ParenExpr).X
|
||||
}
|
||||
|
||||
if types.IdenticalStrict(n.Type(), t) {
|
||||
return n
|
||||
}
|
||||
|
|
|
@ -2184,8 +2184,6 @@ var types2Failures32Bit = setOf(
|
|||
)
|
||||
|
||||
var g3Failures = setOf(
|
||||
"writebarrier.go", // correct diagnostics, but different lines (probably irgen's fault)
|
||||
|
||||
"typeparam/nested.go", // -G=3 doesn't support function-local types with generics
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue