mirror of
https://github.com/golang/go
synced 2024-11-11 23:20:24 -07:00
[dev.typeparams] cmd/compile: fix escape printout bugs for -G=3
Call SetPos() in g.expr() so it is available for any new nodes. Print out the actual type for a composite literal in exprFmt() if available, else use Ntype if available. Seems generally useful, since the type name is always more useful than just 'composite literal'. Fixes a bunch of cases that are excluded in run.go for -G=3. Change-Id: I40b9bba88027ea4f36d419e3989e7f14891bea04 Reviewed-on: https://go-review.googlesource.com/c/go/+/334609 Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
2b10d7ff0b
commit
e3e6cd3022
@ -714,6 +714,10 @@ func exprFmt(n Node, s fmt.State, prec int) {
|
||||
fmt.Fprintf(s, "... argument")
|
||||
return
|
||||
}
|
||||
if typ := n.Type(); typ != nil {
|
||||
fmt.Fprintf(s, "%v{%s}", typ, ellipsisIf(len(n.List) != 0))
|
||||
return
|
||||
}
|
||||
if n.Ntype != nil {
|
||||
fmt.Fprintf(s, "%v{%s}", n.Ntype, ellipsisIf(len(n.List) != 0))
|
||||
return
|
||||
|
@ -88,6 +88,11 @@ func (g *irgen) expr(expr syntax.Expr) ir.Node {
|
||||
|
||||
func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
|
||||
pos := g.pos(expr)
|
||||
assert(pos.IsKnown())
|
||||
|
||||
// Set base.Pos for transformation code that still uses base.Pos, rather than
|
||||
// the pos of the node being converted.
|
||||
base.Pos = pos
|
||||
|
||||
switch expr := expr.(type) {
|
||||
case *syntax.Name:
|
||||
|
34
test/run.go
34
test/run.go
@ -2167,40 +2167,12 @@ var types2Failures32Bit = setOf(
|
||||
)
|
||||
|
||||
var g3Failures = setOf(
|
||||
// TODO: Triage tests without explicit failure explanations. From a
|
||||
// cursory inspection, they mostly fall into:
|
||||
// - Anonymous result parameters given different names (e.g., ~r0 vs ~r1)
|
||||
// - Some escape analysis diagnostics being printed without position information
|
||||
// - Some expressions printed differently (e.g., "int(100)" instead
|
||||
// of "100" or "&composite literal" instead of "&[4]int{...}").
|
||||
|
||||
"closure3.go", // prints "s escapes to heap" without line number
|
||||
"escape2.go",
|
||||
"escape2n.go",
|
||||
"escape4.go", // prints "1 escapes to heap" without line number
|
||||
"escape_calls.go",
|
||||
"escape_field.go",
|
||||
"escape_iface.go",
|
||||
"escape_indir.go",
|
||||
"escape_level.go",
|
||||
"escape_map.go",
|
||||
"escape_param.go",
|
||||
"escape_slice.go",
|
||||
"escape_struct_param1.go",
|
||||
"escape_struct_param2.go",
|
||||
"writebarrier.go", // correct diagnostics, but different lines (probably irgen's fault)
|
||||
|
||||
"fixedbugs/issue12006.go",
|
||||
"fixedbugs/issue13799.go",
|
||||
"writebarrier.go", // correct diagnostics, but different lines (probably irgen's fault)
|
||||
"fixedbugs/issue17270.go", // ICE in irgen
|
||||
"fixedbugs/issue20174.go", // ICE due to width not calculated (probably irgen's fault)
|
||||
"fixedbugs/issue20250.go", // correct diagnostics, but different lines (probably irgen's fault)
|
||||
"fixedbugs/issue21709.go",
|
||||
"fixedbugs/issue31573.go",
|
||||
"fixedbugs/issue37837.go",
|
||||
"fixedbugs/issue39292.go",
|
||||
"fixedbugs/issue7921.go", // prints "composite literal does not escape" but test expects "[]byte{...} does not escape"
|
||||
"fixedbugs/issue9691.go", // "cannot assign to int(.autotmp_4)" (probably irgen's fault)
|
||||
"fixedbugs/issue37837.go", // ICE due to width not calculated
|
||||
"fixedbugs/issue9691.go", // "cannot assign to int(.autotmp_4)" (probably irgen's fault)
|
||||
|
||||
"typeparam/nested.go", // -G=3 doesn't support function-local types with generics
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user