Commit 50520f15 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: use Fatalf for more internal errors

There were a surprising number of places
in the tree that used yyerror for failed internal
consistency checks. Switch them to Fatalf.

Updates #15756
Updates #19250

Change-Id: Ie4278148185795a28ff3c27dacffc211cda5bbdd
Reviewed-on: https://go-review.googlesource.com/38153
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 57107f30
......@@ -106,7 +106,7 @@ func testdclstack() {
if nerrors != 0 {
errorexit()
}
yyerror("mark left on the stack")
Fatalf("mark left on the stack")
}
}
}
......
......@@ -33,7 +33,7 @@ func exportsym(n *Node) {
}
if n.Sym.Export() || n.Sym.Package() {
if n.Sym.Package() {
yyerror("export/package mismatch: %v", n.Sym)
Fatalf("export/package mismatch: %v", n.Sym)
}
return
}
......@@ -220,7 +220,7 @@ func pkgtype(s *Sym) *Type {
}
if s.Def.Type == nil {
yyerror("pkgtype %v", s)
Fatalf("pkgtype %v", s)
}
return s.Def.Type
}
......
......@@ -725,7 +725,7 @@ func (t *Type) typefmt(flag FmtFlag) string {
return "map.iter[" + m.Key().String() + "]" + m.Val().String()
}
yyerror("unknown internal map type")
Fatalf("unknown internal map type")
}
buf := make([]byte, 0, 64)
......
......@@ -192,8 +192,7 @@ func tempname(nn *Node, t *Type) {
}
if t == nil {
yyerror("tempname called with nil type")
t = Types[TINT32]
Fatalf("tempname called with nil type")
}
// give each tmp a different name so that there
......
......@@ -128,7 +128,7 @@ func (a *Mpflt) Float64() float64 {
// check for overflow
if math.IsInf(x, 0) && nsavederrors+nerrors == 0 {
yyerror("ovf in Mpflt Float64")
Fatalf("ovf in Mpflt Float64")
}
return x + 0 // avoid -0 (should not be needed, but be conservative)
......@@ -140,7 +140,7 @@ func (a *Mpflt) Float32() float64 {
// check for overflow
if math.IsInf(x, 0) && nsavederrors+nerrors == 0 {
yyerror("ovf in Mpflt Float32")
Fatalf("ovf in Mpflt Float32")
}
return x + 0 // avoid -0 (should not be needed, but be conservative)
......
......@@ -73,7 +73,7 @@ func (a *Mpint) SetFloat(b *Mpflt) bool {
func (a *Mpint) Add(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Add")
Fatalf("ovf in Mpint Add")
}
a.SetOverflow()
return
......@@ -89,7 +89,7 @@ func (a *Mpint) Add(b *Mpint) {
func (a *Mpint) Sub(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Sub")
Fatalf("ovf in Mpint Sub")
}
a.SetOverflow()
return
......@@ -105,7 +105,7 @@ func (a *Mpint) Sub(b *Mpint) {
func (a *Mpint) Mul(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Mul")
Fatalf("ovf in Mpint Mul")
}
a.SetOverflow()
return
......@@ -121,7 +121,7 @@ func (a *Mpint) Mul(b *Mpint) {
func (a *Mpint) Quo(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Quo")
Fatalf("ovf in Mpint Quo")
}
a.SetOverflow()
return
......@@ -138,7 +138,7 @@ func (a *Mpint) Quo(b *Mpint) {
func (a *Mpint) Rem(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Rem")
Fatalf("ovf in Mpint Rem")
}
a.SetOverflow()
return
......@@ -155,7 +155,7 @@ func (a *Mpint) Rem(b *Mpint) {
func (a *Mpint) Or(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Or")
Fatalf("ovf in Mpint Or")
}
a.SetOverflow()
return
......@@ -167,7 +167,7 @@ func (a *Mpint) Or(b *Mpint) {
func (a *Mpint) And(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint And")
Fatalf("ovf in Mpint And")
}
a.SetOverflow()
return
......@@ -179,7 +179,7 @@ func (a *Mpint) And(b *Mpint) {
func (a *Mpint) AndNot(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint AndNot")
Fatalf("ovf in Mpint AndNot")
}
a.SetOverflow()
return
......@@ -191,7 +191,7 @@ func (a *Mpint) AndNot(b *Mpint) {
func (a *Mpint) Xor(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Xor")
Fatalf("ovf in Mpint Xor")
}
a.SetOverflow()
return
......@@ -203,7 +203,7 @@ func (a *Mpint) Xor(b *Mpint) {
func (a *Mpint) Lsh(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Lsh")
Fatalf("ovf in Mpint Lsh")
}
a.SetOverflow()
return
......@@ -230,7 +230,7 @@ func (a *Mpint) Lsh(b *Mpint) {
func (a *Mpint) Rsh(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("ovf in Mpint Rsh")
Fatalf("ovf in Mpint Rsh")
}
a.SetOverflow()
return
......@@ -268,7 +268,7 @@ func (a *Mpint) Neg() {
func (a *Mpint) Int64() int64 {
if a.Ovf {
if nsavederrors+nerrors == 0 {
yyerror("constant overflow")
Fatalf("constant overflow")
}
return 0
}
......
......@@ -799,8 +799,8 @@ func orderstmt(n *Node, order *Order) {
if r != nil {
switch r.Op {
default:
yyerror("unknown op in select %v", r.Op)
Dump("select case", r)
Fatalf("unknown op in select %v", r.Op)
// If this is case x := <-ch or case x, y := <-ch, the case has
// the ODCL nodes to declare x and y. We want to delay that
......@@ -821,8 +821,8 @@ func orderstmt(n *Node, order *Order) {
}
if r.Ninit.Len() != 0 {
yyerror("ninit on select recv")
dumplist("ninit", r.Ninit)
Fatalf("ninit on select recv")
}
// case x = <-c
......@@ -883,8 +883,8 @@ func orderstmt(n *Node, order *Order) {
case OSEND:
if r.Ninit.Len() != 0 {
yyerror("ninit on select send")
dumplist("ninit", r.Ninit)
Fatalf("ninit on select send")
}
// case c <- x
......
......@@ -90,7 +90,7 @@ func gvardefx(n *Node, as obj.As) {
Fatalf("gvardef nil")
}
if n.Op != ONAME {
yyerror("gvardef %#v; %v", n.Op, n)
Fatalf("gvardef %#v; %v", n.Op, n)
return
}
......
......@@ -751,7 +751,7 @@ func checkauto(fn *Node, p *obj.Prog, n *Node) {
for _, ln := range fn.Func.Dcl {
fmt.Printf("\t%v (%p; class=%d)\n", ln, ln, ln.Class)
}
yyerror("checkauto: invariant lost")
Fatalf("checkauto: invariant lost")
}
func checkparam(fn *Node, p *obj.Prog, n *Node) {
......@@ -768,7 +768,7 @@ func checkparam(fn *Node, p *obj.Prog, n *Node) {
for _, ln := range fn.Func.Dcl {
fmt.Printf("\t%v (%p; class=%d)\n", ln, ln, ln.Class)
}
yyerror("checkparam: invariant lost")
Fatalf("checkparam: invariant lost")
}
func checkprog(fn *Node, p *obj.Prog) {
......@@ -1258,7 +1258,7 @@ func livenessepilogue(lv *Liveness) {
}
n := lv.vars[j]
if n.Class != PPARAM {
yyerrorl(p.Pos, "internal error: %v %L recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, n, p.Pc)
Fatalf("internal error: %v %L recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, n, p.Pc)
}
}
}
......
......@@ -364,13 +364,10 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
OAS2RECV,
OAS2MAPR,
OASOP:
yyerror("instrument: %v must be lowered by now", n.Op)
goto ret
Fatalf("instrument: %v must be lowered by now", n.Op)
case OGETG:
yyerror("instrument: OGETG can happen only in runtime which we don't instrument")
goto ret
Fatalf("instrument: OGETG can happen only in runtime which we don't instrument")
case OFOR, OFORUNTIL:
if n.Left != nil {
......
......@@ -165,7 +165,7 @@ func mapbucket(t *Type) *Type {
// Double-check that overflow field is final memory in struct,
// with no padding at end. See comment above.
if ovf.Offset != bucket.Width-int64(Widthptr) {
yyerror("bad math in mapbucket for %v", t)
Fatalf("bad math in mapbucket for %v", t)
}
t.MapType().Bucket = bucket
......@@ -245,7 +245,7 @@ func hiter(t *Type) *Type {
i.SetFields(field[:])
dowidth(i)
if i.Width != int64(12*Widthptr) {
yyerror("hash_iter size not correct %d %d", i.Width, 12*Widthptr)
Fatalf("hash_iter size not correct %d %d", i.Width, 12*Widthptr)
}
t.MapType().Hiter = i
i.StructType().Map = t
......
......@@ -120,7 +120,7 @@ func adjustargs(n *Node, adjust int) {
callfunc := n.Left
for _, arg = range callfunc.List.Slice() {
if arg.Op != OAS {
yyerror("call arg not assignment")
Fatalf("call arg not assignment")
}
lhs = arg.Left
if lhs.Op == ONAME {
......@@ -130,12 +130,12 @@ func adjustargs(n *Node, adjust int) {
}
if lhs.Op != OINDREGSP {
yyerror("call argument store does not use OINDREGSP")
Fatalf("call argument store does not use OINDREGSP")
}
// can't really check this in machine-indep code.
//if(lhs->val.u.reg != D_SP)
// yyerror("call arg assign not indreg(SP)");
// Fatalf("call arg assign not indreg(SP)")
lhs.Xoffset += int64(adjust)
}
}
......@@ -1694,7 +1694,7 @@ func ascompatee(op Op, nl, nr []*Node, init *Nodes) []*Node {
var nln, nrn Nodes
nln.Set(nl)
nrn.Set(nr)
yyerror("error in shape across %+v %v %+v / %d %d [%s]", nln, op, nrn, len(nl), len(nr), Curfn.Func.Nname.Sym.Name)
Fatalf("error in shape across %+v %v %+v / %d %d [%s]", nln, op, nrn, len(nl), len(nr), Curfn.Func.Nname.Sym.Name)
}
return nn
}
......@@ -1760,7 +1760,7 @@ func ascompatet(op Op, nl Nodes, nr *Type) []*Node {
}
if i < nl.Len() || r != nil {
yyerror("ascompatet: assignment count mismatch: %d = %d", nl.Len(), nr.NumFields())
Fatalf("ascompatet: assignment count mismatch: %d = %d", nl.Len(), nr.NumFields())
}
if ullmanOverflow {
......@@ -2678,7 +2678,7 @@ func addstr(n *Node, init *Nodes) *Node {
c := n.List.Len()
if c < 2 {
yyerror("addstr count %d too small", c)
Fatalf("addstr count %d too small", c)
}
buf := nodnil()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment