]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: fix escape printout bugs for -G=3
authorDan Scales <danscales@google.com>
Wed, 14 Jul 2021 05:21:54 +0000 (22:21 -0700)
committerDan Scales <danscales@google.com>
Wed, 14 Jul 2021 21:58:10 +0000 (21:58 +0000)
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>
src/cmd/compile/internal/ir/fmt.go
src/cmd/compile/internal/noder/expr.go
test/run.go

index 6f6e26dec42ad267684e262d5959a448cb3e2d09..e8dd9df69d04a6fa48d284dd081e7e52beb09a73 100644 (file)
@@ -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
index 16470a54495e380277b67ef34650c1c4c769da33..66ce1bfe4c817cc7a7e852d3efb9044b9a92bbb2 100644 (file)
@@ -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:
index d6209c259154c2fa34b3c774bb6c25ac9086707f..82d49270f26d80c849778c36d268aa27e393bd55 100644 (file)
@@ -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