1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:40:07 -07:00

[dev.unified] cmd/compile: fix unified IR don't report type size too large error

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>
This commit is contained in:
Cuong Manh Le 2022-05-25 23:27:45 +07:00
parent e7ef58542c
commit d6df08693c
2 changed files with 10 additions and 6 deletions

View 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
}

View File

@ -1999,10 +1999,7 @@ var unifiedFailures = setOf(
"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/issue49767.go", // unified IR reports channel element too large on different line than irgen
)
func setOf(keys ...string) map[string]bool {