]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove ir.Node.SetDiag
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 22 Mar 2022 13:55:38 +0000 (20:55 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 23 Mar 2022 19:31:19 +0000 (19:31 +0000)
And use base.Fatalf in code that use n.SetDiag(true) instead.

Updates #51691

Change-Id: Ib3c0b9c89b8d95717391cbe7d424240e288ada1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/394575
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/ir/mini.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/typecheck/const.go
src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/typecheck/stmt.go
src/cmd/compile/internal/typecheck/typecheck.go

index 7bc816356dafc97aee1e5742c01e949898f9079e..801a48a78e4509716692d248f59c5d6640855708 100644 (file)
@@ -7,7 +7,6 @@
 package ir
 
 import (
-       "cmd/compile/internal/base"
        "cmd/compile/internal/types"
        "cmd/internal/src"
        "fmt"
@@ -67,8 +66,6 @@ func (n *miniNode) SetTypecheck(x uint8) {
        n.bits.set2(miniTypecheckShift, x)
 }
 
-func (n *miniNode) SetDiag(x bool) { base.AssertfAt(!x, n.Pos(), "SetDiag") }
-
 func (n *miniNode) Walked() bool     { return n.bits&miniWalked != 0 }
 func (n *miniNode) SetWalked(x bool) { n.bits.set(miniWalked, x) }
 
index 390af6aad21c3f340c90d58a893c3ffcfbacb5f7..5e5868abb2a713051b315893a3d598c3295a6b89 100644 (file)
@@ -46,7 +46,6 @@ type Node interface {
        // Storage for analysis passes.
        Esc() uint16
        SetEsc(x uint16)
-       SetDiag(x bool)
 
        // Typecheck values:
        //  0 means the node is not typechecked
index 79387dd7353053eaf312421eaa37505a081f18da..1422ab003126f1763584b95bd29f7fd81eb50229 100644 (file)
@@ -98,10 +98,7 @@ func convlit1(n ir.Node, t *types.Type, explicit bool, context func() string) ir
                }
                n = ir.Copy(n)
                if t == nil {
-                       base.Errorf("use of untyped nil")
-                       n.SetDiag(true)
-                       n.SetType(nil)
-                       return n
+                       base.Fatalf("use of untyped nil")
                }
 
                if !t.HasNil() {
@@ -199,13 +196,12 @@ func convlit1(n ir.Node, t *types.Type, explicit bool, context func() string) ir
        }
 
        if explicit {
-               base.Errorf("cannot convert %L to type %v", n, t)
+               base.Fatalf("cannot convert %L to type %v", n, t)
        } else if context != nil {
-               base.Errorf("cannot use %L as type %v in %s", n, t, context())
+               base.Fatalf("cannot use %L as type %v in %s", n, t, context())
        } else {
-               base.Errorf("cannot use %L as type %v", n, t)
+               base.Fatalf("cannot use %L as type %v", n, t)
        }
-       n.SetDiag(true)
 
        n.SetType(nil)
        return n
index 50271403415ec79777277cb9fa8325eb33e0fe78..11e5268feb2f1482201dc405c1028b03ae24ea97 100644 (file)
@@ -413,11 +413,7 @@ func tcConv(n *ir.ConvExpr) ir.Node {
        }
        op, why := Convertop(n.X.Op() == ir.OLITERAL, t, n.Type())
        if op == ir.OXXX {
-               base.Errorf("cannot convert %L to type %v%s", n.X, n.Type(), why)
-               n.SetDiag(true)
-               n.SetOp(ir.OCONV)
-               n.SetType(nil)
-               return n
+               base.Fatalf("cannot convert %L to type %v%s", n.X, n.Type(), why)
        }
 
        n.SetOp(op)
index 630a17b7f2b38003de295d41bbc420f5ba6e4451..298af2aeeb7ccd92100e81c82a5c6b81bd4d703c 100644 (file)
@@ -357,8 +357,7 @@ func tcCall(n *ir.CallExpr, top int) ir.Node {
        l = n.X
        if l.Op() == ir.OTYPE {
                if n.IsDDD {
-                       base.Errorf("invalid use of ... in type conversion to %v", l.Type())
-                       n.SetDiag(true)
+                       base.Fatalf("invalid use of ... in type conversion to %v", l.Type())
                }
 
                // pick off before type-checking arguments
index 603b9819b1c35ed15a30f703b3423c4b676f35be..a6ff84e7f6ea7744946961b57cb834bbc433b7f6 100644 (file)
@@ -315,8 +315,7 @@ func tcGoDefer(n *ir.GoDeferStmt) {
 
        // The syntax made sure it was a call, so this must be
        // a conversion.
-       n.SetDiag(true)
-       base.ErrorfAt(n.Pos(), "%s requires function call, not conversion", what)
+       base.FatalfAt(n.Pos(), "%s requires function call, not conversion", what)
 }
 
 // tcIf typechecks an OIF node.
index 7b9e35b4440032197c10af828fcd3e84ef1fd52a..13c19dbdaca2ebfee914ed5ae02d2624172fc030 100644 (file)
@@ -454,10 +454,8 @@ func typecheck1(n ir.Node, top int) ir.Node {
        case ir.ONONAME:
                // Note: adderrorname looks for this string and
                // adds context about the outer expression
-               base.ErrorfAt(n.Pos(), "undefined: %v", n.Sym())
-               n.SetDiag(true)
-               n.SetType(nil)
-               return n
+               base.FatalfAt(n.Pos(), "undefined: %v", n.Sym())
+               panic("unreachable")
 
        case ir.ONAME:
                n := n.(*ir.Name)
@@ -828,8 +826,7 @@ func typecheck1(n ir.Node, top int) ir.Node {
 
        case ir.OTYPESW:
                n := n.(*ir.TypeSwitchGuard)
-               base.Errorf("use of .(type) outside type switch")
-               n.SetDiag(true)
+               base.Fatalf("use of .(type) outside type switch")
                return n
 
        case ir.ODCLFUNC:
@@ -1374,7 +1371,7 @@ notenough:
                        base.Errorf("not enough arguments to %v%s", op, details)
                }
                if n != nil {
-                       n.SetDiag(true)
+                       base.Fatalf("invalid call")
                }
        }
        return
@@ -1521,13 +1518,7 @@ func typecheckarraylit(elemType *types.Type, bound int64, elts []ir.Node, ctx st
                        elt.Key = Expr(elt.Key)
                        key = IndexConst(elt.Key)
                        if key < 0 {
-                               if key == -2 {
-                                       base.Errorf("index too large")
-                               } else {
-                                       base.Errorf("index must be non-negative integer constant")
-                               }
-                               elt.Key.SetDiag(true)
-                               key = -(1 << 30) // stay negative for a while
+                               base.Fatalf("invalid index: %v", elt.Key)
                        }
                        kv = elt
                        r = elt.Value