]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.unified] cmd/compile: fix unified IR don't report type size too large error
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 25 May 2022 16:27:45 +0000 (23:27 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 9 Jun 2022 01:34:20 +0000 (01:34 +0000)
For error reported during type size calculation, base.Pos needs to be
set, otherwise, the compiler will treat them as the same error and only
report once. Old typechecker and irgen all set base.Pos before
processing types, this CL do the same thing for unified IR.

Updates #53058

Change-Id: I686984ffe4aca3e8b14d2103018c8d3c7d71fb02
Reviewed-on: https://go-review.googlesource.com/c/go/+/410345
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/noder/reader.go
test/run.go

index 7c35172f128fba352e8d3f5cc3c4ced8577616f5..d050275f9eb48c552ecaaeb71c9930e94eec42bc 100644 (file)
@@ -599,6 +599,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index, implicits, explicits []*types.Typ
 
        do := func(op ir.Op, hasTParams bool) *ir.Name {
                pos := r.pos()
+               setBasePos(pos)
                if hasTParams {
                        r.typeParamNames()
                }
@@ -1812,6 +1813,7 @@ func (r *reader) exprType(nilOK bool) ir.Node {
        }
 
        pos := r.pos()
+       setBasePos(pos)
 
        lsymPtr := func(lsym *obj.LSym) ir.Node {
                return typecheck.Expr(typecheck.NodAddr(ir.NewLinksymExpr(pos, lsym, types.Types[types.TUINT8])))
@@ -2530,3 +2532,8 @@ func addTailCall(pos src.XPos, fn *ir.Func, recv ir.Node, method *types.Field) {
        ret.Results = []ir.Node{call}
        fn.Body.Append(ret)
 }
+
+func setBasePos(pos src.XPos) {
+       // Set the position for any error messages we might print (e.g. too large types).
+       base.Pos = pos
+}
index a4ec19c73c0d54582d9694525ba72f0fd36787e3..8763660ea848f8c53d31b0caebba32af763b1e61 100644 (file)
@@ -1997,12 +1997,9 @@ var unifiedFailures = setOf(
        "escape4.go",  // unified IR can inline f5 and f6; test doesn't expect this
        "inline.go",   // unified IR reports function literal diagnostics on different lines than -d=inlfuncswithclosures
 
-       "fixedbugs/issue7921.go",   // prints "… escapes to heap", but test expects "string(…) escapes to heap"
-       "typeparam/issue47631.go",  // unified IR can handle local type declarations
-       "fixedbugs/issue42058a.go", // unified IR doesn't report channel element too large
-       "fixedbugs/issue42058b.go", // unified IR doesn't report channel element too large
-       "fixedbugs/issue49767.go",  // unified IR doesn't report channel element too large
-       "fixedbugs/issue49814.go",  // unified IR doesn't report array type too large
+       "fixedbugs/issue7921.go",  // prints "… escapes to heap", but test expects "string(…) escapes to heap"
+       "typeparam/issue47631.go", // unified IR can handle local type declarations
+       "fixedbugs/issue49767.go", // unified IR reports channel element too large on different line than irgen
 )
 
 func setOf(keys ...string) map[string]bool {