mirror of
https://github.com/golang/go
synced 2024-11-24 14:40:15 -07:00
cmd/compile: remove ir.Node.SetDiag
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>
This commit is contained in:
parent
515135f4c3
commit
c10fb50894
@ -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) }
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user