From d6df08693cd1639a7d9f0df292b4aa469b1cd748 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 25 May 2022 23:27:45 +0700 Subject: [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 Run-TryBot: Cuong Manh Le Reviewed-by: Cherry Mui Reviewed-by: Keith Randall Reviewed-by: Keith Randall --- src/cmd/compile/internal/noder/reader.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/cmd/compile/internal/noder') diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index 7c35172f12..d050275f9e 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -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 +} -- cgit v1.3-5-g9baa