[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge of master into dev.ssa.
Change-Id: I48aa17700096a14f2a20ad07491ebfcd7529f6d5
diff --git a/src/cmd/compile/internal/gc/align.go b/src/cmd/compile/internal/gc/align.go
index 60c59fc..741588e 100644
--- a/src/cmd/compile/internal/gc/align.go
+++ b/src/cmd/compile/internal/gc/align.go
@@ -16,7 +16,7 @@
func Rnd(o int64, r int64) int64 {
if r < 1 || r > 8 || r&(r-1) != 0 {
- Fatal("rnd %d", r)
+ Fatalf("rnd %d", r)
}
return (o + r - 1) &^ (r - 1)
}
@@ -25,7 +25,7 @@
o := int32(0)
for f := t.Type; f != nil; f = f.Down {
if f.Etype != TFIELD {
- Fatal("offmod: not TFIELD: %v", Tconv(f, obj.FmtLong))
+ Fatalf("offmod: not TFIELD: %v", Tconv(f, obj.FmtLong))
}
f.Width = int64(o)
o += int32(Widthptr)
@@ -46,7 +46,7 @@
var w int64
for f := t.Type; f != nil; f = f.Down {
if f.Etype != TFIELD {
- Fatal("widstruct: not TFIELD: %v", Tconv(f, obj.FmtLong))
+ Fatalf("widstruct: not TFIELD: %v", Tconv(f, obj.FmtLong))
}
if f.Type == nil {
// broken field, just skip it so that other valid fields
@@ -59,7 +59,7 @@
maxalign = int32(f.Type.Align)
}
if f.Type.Width < 0 {
- Fatal("invalid width %d", f.Type.Width)
+ Fatalf("invalid width %d", f.Type.Width)
}
w = f.Type.Width
if f.Type.Align > 0 {
@@ -111,7 +111,7 @@
func dowidth(t *Type) {
if Widthptr == 0 {
- Fatal("dowidth without betypeinit")
+ Fatalf("dowidth without betypeinit")
}
if t == nil {
@@ -121,7 +121,7 @@
if t.Width > 0 {
if t.Align == 0 {
// See issue 11354
- Fatal("zero alignment with nonzero size %v", t)
+ Fatalf("zero alignment with nonzero size %v", t)
}
return
}
@@ -129,8 +129,8 @@
if t.Width == -2 {
lno := int(lineno)
lineno = int32(t.Lineno)
- if t.Broke == 0 {
- t.Broke = 1
+ if !t.Broke {
+ t.Broke = true
Yyerror("invalid recursive type %v", t)
}
@@ -141,7 +141,7 @@
// break infinite recursion if the broken recursive type
// is referenced again
- if t.Broke != 0 && t.Width == 0 {
+ if t.Broke && t.Width == 0 {
return
}
@@ -168,7 +168,7 @@
w := int64(0)
switch et {
default:
- Fatal("dowidth: unknown type: %v", t)
+ Fatalf("dowidth: unknown type: %v", t)
/* compiler-specific stuff */
case TINT8, TUINT8, TBOOL:
@@ -233,7 +233,7 @@
checkwidth(t.Down)
case TFORW: // should have been filled in
- if t.Broke == 0 {
+ if !t.Broke {
Yyerror("invalid recursive type %v", t)
}
w = 1 // anything will do
@@ -241,13 +241,13 @@
// dummy type; should be replaced before use.
case TANY:
if Debug['A'] == 0 {
- Fatal("dowidth any")
+ Fatalf("dowidth any")
}
w = 1 // anything will do
case TSTRING:
if sizeof_String == 0 {
- Fatal("early dowidth string")
+ Fatalf("early dowidth string")
}
w = int64(sizeof_String)
t.Align = uint8(Widthptr)
@@ -272,17 +272,17 @@
checkwidth(t.Type)
t.Align = uint8(Widthptr)
} else if t.Bound == -100 {
- if t.Broke == 0 {
+ if !t.Broke {
Yyerror("use of [...] array outside of array literal")
- t.Broke = 1
+ t.Broke = true
}
} else {
- Fatal("dowidth %v", t) // probably [...]T
+ Fatalf("dowidth %v", t) // probably [...]T
}
case TSTRUCT:
- if t.Funarg != 0 {
- Fatal("dowidth fn struct %v", t)
+ if t.Funarg {
+ Fatalf("dowidth fn struct %v", t)
}
w = widstruct(t, t, 0, 1)
@@ -319,7 +319,7 @@
t.Width = w
if t.Align == 0 {
if w > 8 || w&(w-1) != 0 {
- Fatal("invalid alignment for %v", t)
+ Fatalf("invalid alignment for %v", t)
}
t.Align = uint8(w)
}
@@ -366,8 +366,8 @@
// function arg structs should not be checked
// outside of the enclosing function.
- if t.Funarg != 0 {
- Fatal("checkwidth %v", t)
+ if t.Funarg {
+ Fatalf("checkwidth %v", t)
}
if defercalc == 0 {
@@ -375,10 +375,10 @@
return
}
- if t.Deferwidth != 0 {
+ if t.Deferwidth {
return
}
- t.Deferwidth = 1
+ t.Deferwidth = true
l := tlfree
if l != nil {
@@ -395,17 +395,17 @@
func defercheckwidth() {
// we get out of sync on syntax errors, so don't be pedantic.
if defercalc != 0 && nerrors == 0 {
- Fatal("defercheckwidth")
+ Fatalf("defercheckwidth")
}
defercalc = 1
}
func resumecheckwidth() {
if defercalc == 0 {
- Fatal("resumecheckwidth")
+ Fatalf("resumecheckwidth")
}
for l := tlq; l != nil; l = tlq {
- l.t.Deferwidth = 0
+ l.t.Deferwidth = false
tlq = l.next
dowidth(l.t)
l.next = tlfree
@@ -419,7 +419,7 @@
func typeinit() {
if Widthptr == 0 {
- Fatal("typeinit before betypeinit")
+ Fatalf("typeinit before betypeinit")
}
for i := 0; i < NTYPE; i++ {
@@ -637,11 +637,11 @@
etype = Thearch.Typedefs[i].Etype
if etype < 0 || etype >= len(Types) {
- Fatal("typeinit: %s bad etype", s.Name)
+ Fatalf("typeinit: %s bad etype", s.Name)
}
sameas = Thearch.Typedefs[i].Sameas
if sameas < 0 || sameas >= len(Types) {
- Fatal("typeinit: %s bad sameas", s.Name)
+ Fatalf("typeinit: %s bad sameas", s.Name)
}
Simtype[etype] = uint8(sameas)
minfltval[etype] = minfltval[sameas]
@@ -651,7 +651,7 @@
t = Types[etype]
if t != nil {
- Fatal("typeinit: %s already defined", s.Name)
+ Fatalf("typeinit: %s already defined", s.Name)
}
t = typ(etype)
@@ -707,7 +707,7 @@
w = (w + int64(Widthptr) - 1) &^ (int64(Widthptr) - 1)
if int64(int(w)) != w {
- Fatal("argsize too big")
+ Fatalf("argsize too big")
}
return int(w)
}
diff --git a/src/cmd/compile/internal/gc/bv.go b/src/cmd/compile/internal/gc/bv.go
index 2b988e6..b40339e 100644
--- a/src/cmd/compile/internal/gc/bv.go
+++ b/src/cmd/compile/internal/gc/bv.go
@@ -65,7 +65,7 @@
func bvcmp(bv1 Bvec, bv2 Bvec) int {
if bv1.n != bv2.n {
- Fatal("bvequal: lengths %d and %d are not equal", bv1.n, bv2.n)
+ Fatalf("bvequal: lengths %d and %d are not equal", bv1.n, bv2.n)
}
for i, x := range bv1.b {
if x != bv2.b[i] {
@@ -98,7 +98,7 @@
func bvget(bv Bvec, i int32) int {
if i < 0 || i >= bv.n {
- Fatal("bvget: index %d is out of bounds with length %d\n", i, bv.n)
+ Fatalf("bvget: index %d is out of bounds with length %d\n", i, bv.n)
}
return int((bv.b[i>>WORDSHIFT] >> uint(i&WORDMASK)) & 1)
}
@@ -174,7 +174,7 @@
func bvreset(bv Bvec, i int32) {
if i < 0 || i >= bv.n {
- Fatal("bvreset: index %d is out of bounds with length %d\n", i, bv.n)
+ Fatalf("bvreset: index %d is out of bounds with length %d\n", i, bv.n)
}
mask := uint32(^(1 << uint(i%WORDBITS)))
bv.b[i/WORDBITS] &= mask
@@ -188,7 +188,7 @@
func bvset(bv Bvec, i int32) {
if i < 0 || i >= bv.n {
- Fatal("bvset: index %d is out of bounds with length %d\n", i, bv.n)
+ Fatalf("bvset: index %d is out of bounds with length %d\n", i, bv.n)
}
mask := uint32(1 << uint(i%WORDBITS))
bv.b[i/WORDBITS] |= mask
diff --git a/src/cmd/compile/internal/gc/cgen.go b/src/cmd/compile/internal/gc/cgen.go
index b6a3e5b..951f84f 100644
--- a/src/cmd/compile/internal/gc/cgen.go
+++ b/src/cmd/compile/internal/gc/cgen.go
@@ -34,7 +34,7 @@
}
if res == nil || res.Type == nil {
- Fatal("cgen: res nil")
+ Fatalf("cgen: res nil")
}
for n.Op == OCONVNOP {
@@ -68,7 +68,7 @@
if n.Ullman >= UINF {
if n.Op == OINDREG {
- Fatal("cgen: this is going to miscompile")
+ Fatalf("cgen: this is going to miscompile")
}
if res.Ullman >= UINF {
var n1 Node
@@ -81,7 +81,7 @@
if Isfat(n.Type) {
if n.Type.Width < 0 {
- Fatal("forgot to compute width for %v", n.Type)
+ Fatalf("forgot to compute width for %v", n.Type)
}
sgen_wb(n, res, n.Type.Width, wb)
return
@@ -103,7 +103,7 @@
if n1.Ullman > res.Ullman {
Dump("n1", &n1)
Dump("res", res)
- Fatal("loop in cgen")
+ Fatalf("loop in cgen")
}
cgen_wb(&n1, res, wb)
@@ -191,7 +191,7 @@
if wb {
if int(Simtype[res.Type.Etype]) != Tptr {
- Fatal("cgen_wb of type %v", res.Type)
+ Fatalf("cgen_wb of type %v", res.Type)
}
if n.Ullman >= UINF {
var n1 Node
@@ -362,7 +362,7 @@
default:
Dump("cgen", n)
Dump("cgen-res", res)
- Fatal("cgen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
+ Fatalf("cgen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
case OOROR, OANDAND,
OEQ, ONE,
@@ -593,7 +593,7 @@
break
}
- Fatal("cgen: OLEN: unknown type %v", Tconv(nl.Type, obj.FmtLong))
+ Fatalf("cgen: OLEN: unknown type %v", Tconv(nl.Type, obj.FmtLong))
case OCAP:
if Istype(nl.Type, TCHAN) {
@@ -631,7 +631,7 @@
break
}
- Fatal("cgen: OCAP: unknown type %v", Tconv(nl.Type, obj.FmtLong))
+ Fatalf("cgen: OCAP: unknown type %v", Tconv(nl.Type, obj.FmtLong))
case OADDR:
if n.Bounded { // let race detector avoid nil checks
@@ -705,9 +705,7 @@
*/
sbop: // symmetric binary
if nl.Ullman < nr.Ullman || (nl.Ullman == nr.Ullman && (Smallintconst(nl) || (nr.Op == OLITERAL && !Smallintconst(nr)))) {
- r := nl
- nl = nr
- nr = r
+ nl, nr = nr, nl
}
abop: // asymmetric binary
@@ -928,7 +926,7 @@
}
if Isfat(n.Type) {
- Fatal("cgenr on fat node")
+ Fatalf("cgenr on fat node")
}
if n.Addable {
@@ -1034,7 +1032,7 @@
// constant index
if Isconst(nr, CTINT) {
if Isconst(nl, CTSTR) {
- Fatal("constant string constant index")
+ Fatalf("constant string constant index")
}
v := uint64(Mpgetfix(nr.Val().U.(*Mpint)))
var n2 Node
@@ -1186,7 +1184,7 @@
// constant index
if Isconst(nr, CTINT) {
if Isconst(nl, CTSTR) {
- Fatal("constant string constant index") // front end should handle
+ Fatalf("constant string constant index") // front end should handle
}
v := uint64(Mpgetfix(nr.Val().U.(*Mpint)))
if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
@@ -1376,7 +1374,7 @@
index:
if Isconst(nr, CTINT) {
if Isconst(nl, CTSTR) {
- Fatal("constant string constant index") // front end should handle
+ Fatalf("constant string constant index") // front end should handle
}
v := uint64(Mpgetfix(nr.Val().U.(*Mpint)))
if Isslice(nl.Type) || nl.Type.Etype == TSTRING {
@@ -1529,7 +1527,7 @@
if n.Addable {
if n.Op == OREGISTER {
- Fatal("agen OREGISTER")
+ Fatalf("agen OREGISTER")
}
var n1 Node
n1.Op = OADDR
@@ -1546,7 +1544,7 @@
switch n.Op {
default:
- Fatal("agen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
+ Fatalf("agen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
case OCALLMETH:
cgen_callmeth(n, 0)
@@ -1576,13 +1574,13 @@
// should only get here with names in this func.
if n.Name.Funcdepth > 0 && n.Name.Funcdepth != Funcdepth {
Dump("bad agen", n)
- Fatal("agen: bad ONAME funcdepth %d != %d", n.Name.Funcdepth, Funcdepth)
+ Fatalf("agen: bad ONAME funcdepth %d != %d", n.Name.Funcdepth, Funcdepth)
}
// should only get here for heap vars or paramref
if n.Class&PHEAP == 0 && n.Class != PPARAMREF {
Dump("bad agen", n)
- Fatal("agen: bad ONAME class %#x", n.Class)
+ Fatalf("agen: bad ONAME class %#x", n.Class)
}
Cgen(n.Name.Heapaddr, res)
@@ -1800,7 +1798,7 @@
}
if n.Type.Etype != TBOOL {
- Fatal("bgen: bad type %v for %v", n.Type, Oconv(int(n.Op), 0))
+ Fatalf("bgen: bad type %v for %v", n.Type, Oconv(int(n.Op), 0))
}
for n.Op == OCONVNOP {
@@ -1841,7 +1839,7 @@
// We can fix that as we go.
switch Ctxt.Arch.Thechar {
case '5', '7', '9':
- Fatal("genval 5g, 7g, 9g ONAMES not fully implemented")
+ Fatalf("genval 5g, 7g, 9g ONAMES not fully implemented")
}
Cgen(n, res)
if !wantTrue {
@@ -1865,7 +1863,7 @@
case OLITERAL:
// n is a constant.
if !Isconst(n, CTBOOL) {
- Fatal("bgen: non-bool const %v\n", Nconv(n, obj.FmtLong))
+ Fatalf("bgen: non-bool const %v\n", Nconv(n, obj.FmtLong))
}
if genval {
Cgen(Nodbool(wantTrue == n.Val().U.(bool)), res)
@@ -2068,7 +2066,7 @@
switch Ctxt.Arch.Thechar {
case '5':
if genval {
- Fatal("genval 5g Isfloat special cases not implemented")
+ Fatalf("genval 5g Isfloat special cases not implemented")
}
switch n.Op {
case ONE:
@@ -2116,7 +2114,7 @@
}
case '7', '9':
if genval {
- Fatal("genval 7g, 9g Isfloat special cases not implemented")
+ Fatalf("genval 7g, 9g Isfloat special cases not implemented")
}
switch n.Op {
// On arm64 and ppc64, <= and >= mishandle NaN. Must decompose into < or > and =.
@@ -2251,11 +2249,11 @@
}
if n.Ullman >= UINF && ns.Ullman >= UINF {
- Fatal("sgen UINF")
+ Fatalf("sgen UINF")
}
if w < 0 {
- Fatal("sgen copy %d", w)
+ Fatalf("sgen copy %d", w)
}
// If copying .args, that's all the results, so record definition sites
@@ -2336,7 +2334,7 @@
switch proc {
default:
- Fatal("Ginscall: bad proc %d", proc)
+ Fatalf("Ginscall: bad proc %d", proc)
case 0, // normal call
-1: // normal call but no return
@@ -2401,8 +2399,8 @@
if proc == 1 {
Ginscall(Newproc, 0)
} else {
- if Hasdefer == 0 {
- Fatal("hasdefer=0 but has defer")
+ if !hasdefer {
+ Fatalf("hasdefer=0 but has defer")
}
Ginscall(Deferproc, 0)
}
@@ -2423,12 +2421,12 @@
func cgen_callinter(n *Node, res *Node, proc int) {
i := n.Left
if i.Op != ODOTINTER {
- Fatal("cgen_callinter: not ODOTINTER %v", Oconv(int(i.Op), 0))
+ Fatalf("cgen_callinter: not ODOTINTER %v", Oconv(int(i.Op), 0))
}
f := i.Right // field
if f.Op != ONAME {
- Fatal("cgen_callinter: not ONAME %v", Oconv(int(f.Op), 0))
+ Fatalf("cgen_callinter: not ONAME %v", Oconv(int(f.Op), 0))
}
i = i.Left // interface
@@ -2471,7 +2469,7 @@
var nodr Node
Regalloc(&nodr, Types[Tptr], &nodo)
if n.Left.Xoffset == BADWIDTH {
- Fatal("cgen_callinter: badwidth")
+ Fatalf("cgen_callinter: badwidth")
}
Cgen_checknil(&nodo) // in case offset is huge
nodo.Op = OINDREG
@@ -2562,7 +2560,7 @@
var flist Iter
fp := Structfirst(&flist, Getoutarg(t))
if fp == nil {
- Fatal("cgen_callret: nil")
+ Fatalf("cgen_callret: nil")
}
var nod Node
@@ -2592,7 +2590,7 @@
var flist Iter
fp := Structfirst(&flist, Getoutarg(t))
if fp == nil {
- Fatal("cgen_aret: nil")
+ Fatalf("cgen_aret: nil")
}
var nod1 Node
@@ -2624,7 +2622,7 @@
if n != nil {
Genlist(n.List) // copy out args
}
- if Hasdefer != 0 {
+ if hasdefer {
Ginscall(Deferreturn, 0)
}
Genlist(Curfn.Func.Exit)
@@ -2814,11 +2812,11 @@
if res.Op != ONAME && !samesafeexpr(res, n.List.N) {
Dump("cgen_append-n", n)
Dump("cgen_append-res", res)
- Fatal("append not lowered")
+ Fatalf("append not lowered")
}
for l := n.List; l != nil; l = l.Next {
if l.N.Ullman >= UINF {
- Fatal("append with function call arguments")
+ Fatalf("append with function call arguments")
}
}
@@ -3261,7 +3259,7 @@
// but it will be represented in 32 bits.
if Ctxt.Arch.Regsize == 4 && Is64(n1.Type) {
if mpcmpfixc(n1.Val().U.(*Mpint), 1<<31) >= 0 {
- Fatal("missed slice out of bounds check")
+ Fatalf("missed slice out of bounds check")
}
var tmp Node
Nodconst(&tmp, indexRegType, Mpgetfix(n1.Val().U.(*Mpint)))
diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go
index a0dfa0b..e7bece8 100644
--- a/src/cmd/compile/internal/gc/closure.go
+++ b/src/cmd/compile/internal/gc/closure.go
@@ -87,7 +87,7 @@
if !n.Name.Captured {
n.Name.Captured = true
if n.Name.Decldepth == 0 {
- Fatal("typecheckclosure: var %v does not have decldepth assigned", Nconv(n, obj.FmtShort))
+ Fatalf("typecheckclosure: var %v does not have decldepth assigned", Nconv(n, obj.FmtShort))
}
// Ignore assignments to the variable in straightline code
@@ -172,7 +172,7 @@
n.Func.Outerfunc.Func.Closgen++
gen = n.Func.Outerfunc.Func.Closgen
} else {
- Fatal("closurename called for %v", Nconv(n, obj.FmtShort))
+ Fatalf("closurename called for %v", Nconv(n, obj.FmtShort))
}
n.Sym = Lookupf("%s.%s%d", outer, prefix, gen)
return n.Sym
@@ -204,7 +204,7 @@
xfunc.Nbody = func_.Nbody
xfunc.Func.Dcl = concat(func_.Func.Dcl, xfunc.Func.Dcl)
if xfunc.Nbody == nil {
- Fatal("empty body - won't generate any code")
+ Fatalf("empty body - won't generate any code")
}
typecheck(&xfunc, Etop)
@@ -322,7 +322,7 @@
continue
}
fld = typ(TFIELD)
- fld.Funarg = 1
+ fld.Funarg = true
if v.Name.Byval {
// If v is captured by value, we merely downgrade it to PPARAM.
v.Class = PPARAM
@@ -355,7 +355,7 @@
// Recalculate param offsets.
if f.Type.Width > 0 {
- Fatal("transformclosure: width is already calculated")
+ Fatalf("transformclosure: width is already calculated")
}
dowidth(f.Type)
xfunc.Type = f.Type // update type of ODCLFUNC
@@ -491,7 +491,7 @@
break
default:
- Fatal("invalid typecheckpartialcall")
+ Fatalf("invalid typecheckpartialcall")
}
// Create top-level function.
@@ -518,7 +518,7 @@
basetype = basetype.Type
}
if basetype.Etype != TINTER && basetype.Sym == nil {
- Fatal("missing base type for %v", rcvrtype)
+ Fatalf("missing base type for %v", rcvrtype)
}
var spkg *Pkg
diff --git a/src/cmd/compile/internal/gc/const.go b/src/cmd/compile/internal/gc/const.go
index 9eb4983..de23190 100644
--- a/src/cmd/compile/internal/gc/const.go
+++ b/src/cmd/compile/internal/gc/const.go
@@ -14,7 +14,7 @@
// n must be an integer constant.
func (n *Node) Int() int64 {
if !Isconst(n, CTINT) {
- Fatal("Int(%v)", n)
+ Fatalf("Int(%v)", n)
}
return Mpgetfix(n.Val().U.(*Mpint))
}
@@ -23,7 +23,7 @@
// n must be an integer constant.
func (n *Node) SetInt(i int64) {
if !Isconst(n, CTINT) {
- Fatal("SetInt(%v)", n)
+ Fatalf("SetInt(%v)", n)
}
Mpmovecfix(n.Val().U.(*Mpint), i)
}
@@ -32,7 +32,7 @@
// n must be an integer constant.
func (n *Node) SetBigInt(x *big.Int) {
if !Isconst(n, CTINT) {
- Fatal("SetBigInt(%v)", n)
+ Fatalf("SetBigInt(%v)", n)
}
n.Val().U.(*Mpint).Val.Set(x)
}
@@ -41,7 +41,7 @@
// n must be an boolean constant.
func (n *Node) Bool() bool {
if !Isconst(n, CTBOOL) {
- Fatal("Int(%v)", n)
+ Fatalf("Int(%v)", n)
}
return n.Val().U.(bool)
}
@@ -292,7 +292,7 @@
bad:
if n.Diag == 0 {
- if t.Broke == 0 {
+ if !t.Broke {
Yyerror("cannot convert %v to type %v", n, t)
}
n.Diag = 1
@@ -396,7 +396,7 @@
switch v.Ctype() {
case CTINT, CTRUNE:
if !Isint[t.Etype] {
- Fatal("overflow: %v integer constant", t)
+ Fatalf("overflow: %v integer constant", t)
}
if Mpcmpfixfix(v.U.(*Mpint), Minintval[t.Etype]) < 0 || Mpcmpfixfix(v.U.(*Mpint), Maxintval[t.Etype]) > 0 {
return true
@@ -404,7 +404,7 @@
case CTFLT:
if !Isfloat[t.Etype] {
- Fatal("overflow: %v floating-point constant", t)
+ Fatalf("overflow: %v floating-point constant", t)
}
if mpcmpfltflt(v.U.(*Mpflt), minfltval[t.Etype]) <= 0 || mpcmpfltflt(v.U.(*Mpflt), maxfltval[t.Etype]) >= 0 {
return true
@@ -412,7 +412,7 @@
case CTCPLX:
if !Iscomplex[t.Etype] {
- Fatal("overflow: %v complex constant", t)
+ Fatalf("overflow: %v complex constant", t)
}
if mpcmpfltflt(&v.U.(*Mpcplx).Real, minfltval[t.Etype]) <= 0 || mpcmpfltflt(&v.U.(*Mpcplx).Real, maxfltval[t.Etype]) >= 0 || mpcmpfltflt(&v.U.(*Mpcplx).Imag, minfltval[t.Etype]) <= 0 || mpcmpfltflt(&v.U.(*Mpcplx).Imag, maxfltval[t.Etype]) >= 0 {
return true
@@ -787,7 +787,7 @@
if (v.Ctype() == 0 || rv.Ctype() == 0) && nerrors > 0 {
return
}
- Fatal("constant type mismatch %v(%d) %v(%d)", nl.Type, v.Ctype(), nr.Type, rv.Ctype())
+ Fatalf("constant type mismatch %v(%d) %v(%d)", nl.Type, v.Ctype(), nr.Type, rv.Ctype())
}
// run op
@@ -1106,7 +1106,7 @@
n.SetVal(v)
switch v.Ctype() {
default:
- Fatal("nodlit ctype %d", v.Ctype())
+ Fatalf("nodlit ctype %d", v.Ctype())
case CTSTR:
n.Type = idealstring
@@ -1134,7 +1134,7 @@
n.SetVal(Val{c})
if r.Ctype() != CTFLT || i.Ctype() != CTFLT {
- Fatal("nodcplxlit ctype %d/%d", r.Ctype(), i.Ctype())
+ Fatalf("nodcplxlit ctype %d/%d", r.Ctype(), i.Ctype())
}
mpmovefltflt(&c.Real, r.U.(*Mpflt))
@@ -1249,7 +1249,7 @@
Yyerror("defaultlit: unknown literal: %v", n)
case CTxxx:
- Fatal("defaultlit: idealkind is CTxxx: %v", Nconv(n, obj.FmtSign))
+ Fatalf("defaultlit: idealkind is CTxxx: %v", Nconv(n, obj.FmtSign))
case CTBOOL:
t1 := Types[TBOOL]
@@ -1450,7 +1450,7 @@
var i int64
switch n.Val().Ctype() {
default:
- Fatal("convconst ctype=%d %v", n.Val().Ctype(), Tconv(t, obj.FmtLong))
+ Fatalf("convconst ctype=%d %v", n.Val().Ctype(), Tconv(t, obj.FmtLong))
case CTINT, CTRUNE:
i = Mpgetfix(n.Val().U.(*Mpint))
@@ -1470,7 +1470,7 @@
if Isfloat[tt] {
con.SetVal(toflt(con.Val()))
if con.Val().Ctype() != CTFLT {
- Fatal("convconst ctype=%d %v", con.Val().Ctype(), t)
+ Fatalf("convconst ctype=%d %v", con.Val().Ctype(), t)
}
if tt == TFLOAT32 {
con.SetVal(Val{truncfltlit(con.Val().U.(*Mpflt), t)})
@@ -1487,7 +1487,7 @@
return
}
- Fatal("convconst %v constant", Tconv(t, obj.FmtLong))
+ Fatalf("convconst %v constant", Tconv(t, obj.FmtLong))
}
// complex multiply v *= rv
diff --git a/src/cmd/compile/internal/gc/cplx.go b/src/cmd/compile/internal/gc/cplx.go
index 1643f26..9f11b96 100644
--- a/src/cmd/compile/internal/gc/cplx.go
+++ b/src/cmd/compile/internal/gc/cplx.go
@@ -81,7 +81,7 @@
// break addable nc-complex into nr-real and ni-imaginary
func subnode(nr *Node, ni *Node, nc *Node) {
if !nc.Addable {
- Fatal("subnode not addable")
+ Fatalf("subnode not addable")
}
tc := Simsimtype(nc.Type)
@@ -230,7 +230,7 @@
n.Type = t
if !Isfloat[t.Etype] {
- Fatal("nodfconst: bad type %v", t)
+ Fatalf("nodfconst: bad type %v", t)
}
}
@@ -288,14 +288,14 @@
}
if !t.Addable {
- Fatal("complexmove: to not addable")
+ Fatalf("complexmove: to not addable")
}
ft := Simsimtype(f.Type)
tt := Simsimtype(t.Type)
switch uint32(ft)<<16 | uint32(tt) {
default:
- Fatal("complexmove: unknown conversion: %v -> %v\n", f.Type, t.Type)
+ Fatalf("complexmove: unknown conversion: %v -> %v\n", f.Type, t.Type)
// complex to complex move/convert.
// make f addable.
@@ -403,7 +403,7 @@
switch n.Op {
default:
Dump("complexgen: unknown op", n)
- Fatal("complexgen: unknown op %v", Oconv(int(n.Op), 0))
+ Fatalf("complexgen: unknown op %v", Oconv(int(n.Op), 0))
case ODOT,
ODOTPTR,
@@ -462,7 +462,7 @@
switch n.Op {
default:
- Fatal("complexgen: unknown op %v", Oconv(int(n.Op), 0))
+ Fatalf("complexgen: unknown op %v", Oconv(int(n.Op), 0))
case OCONV:
Complexmove(nl, res)
diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go
index c8864f3..0609274 100644
--- a/src/cmd/compile/internal/gc/dcl.go
+++ b/src/cmd/compile/internal/gc/dcl.go
@@ -73,7 +73,7 @@
}
if d == nil {
- Fatal("popdcl: no mark")
+ Fatalf("popdcl: no mark")
}
dclstack = d.Link
block = d.Block
@@ -182,7 +182,7 @@
s := n.Sym
// kludgy: typecheckok means we're past parsing. Eg genwrapper may declare out of package names later.
- if importpkg == nil && typecheckok == 0 && s.Pkg != localpkg {
+ if importpkg == nil && !typecheckok && s.Pkg != localpkg {
Yyerror("cannot declare name %v", s)
}
@@ -198,7 +198,7 @@
}
} else {
if Curfn == nil && ctxt == PAUTO {
- Fatal("automatic outside function")
+ Fatalf("automatic outside function")
}
if Curfn != nil {
Curfn.Func.Dcl = list(Curfn.Func.Dcl, n)
@@ -238,7 +238,7 @@
func addvar(n *Node, t *Type, ctxt uint8) {
if n == nil || n.Sym == nil || (n.Op != ONAME && n.Op != ONONAME) || t == nil {
- Fatal("addvar: n=%v t=%v nil", n, t)
+ Fatalf("addvar: n=%v t=%v nil", n, t)
}
n.Op = ONAME
@@ -366,7 +366,7 @@
*/
func newname(s *Sym) *Node {
if s == nil {
- Fatal("newname nil")
+ Fatalf("newname nil")
}
n := Nod(ONAME, nil, nil)
@@ -548,7 +548,7 @@
*/
func ifacedcl(n *Node) {
if n.Op != ODCLFIELD || n.Right == nil {
- Fatal("ifacedcl")
+ Fatalf("ifacedcl")
}
if isblank(n.Left) {
@@ -582,7 +582,7 @@
func funchdr(n *Node) {
// change the declaration context from extern to auto
if Funcdepth == 0 && dclcontext != PEXTERN {
- Fatal("funchdr: dclcontext")
+ Fatalf("funchdr: dclcontext")
}
if importpkg == nil && n.Func.Nname != nil {
@@ -607,7 +607,7 @@
func funcargs(nt *Node) {
if nt.Op != OTFUNC {
- Fatal("funcargs %v", Oconv(int(nt.Op), 0))
+ Fatalf("funcargs %v", Oconv(int(nt.Op), 0))
}
// re-start the variable generation number
@@ -621,7 +621,7 @@
if nt.Left != nil {
n := nt.Left
if n.Op != ODCLFIELD {
- Fatal("funcargs receiver %v", Oconv(int(n.Op), 0))
+ Fatalf("funcargs receiver %v", Oconv(int(n.Op), 0))
}
if n.Left != nil {
n.Left.Op = ONAME
@@ -638,7 +638,7 @@
for l := nt.List; l != nil; l = l.Next {
n = l.N
if n.Op != ODCLFIELD {
- Fatal("funcargs in %v", Oconv(int(n.Op), 0))
+ Fatalf("funcargs in %v", Oconv(int(n.Op), 0))
}
if n.Left != nil {
n.Left.Op = ONAME
@@ -659,7 +659,7 @@
n = l.N
if n.Op != ODCLFIELD {
- Fatal("funcargs out %v", Oconv(int(n.Op), 0))
+ Fatalf("funcargs out %v", Oconv(int(n.Op), 0))
}
if n.Left == nil {
@@ -705,7 +705,7 @@
*/
func funcargs2(t *Type) {
if t.Etype != TFUNC {
- Fatal("funcargs2 %v", t)
+ Fatalf("funcargs2 %v", t)
}
if t.Thistuple != 0 {
@@ -753,7 +753,7 @@
func funcbody(n *Node) {
// change the declaration context from auto to extern
if dclcontext != PAUTO {
- Fatal("funcbody: dclcontext")
+ Fatalf("funcbody: dclcontext")
}
popdcl()
Funcdepth--
@@ -813,7 +813,7 @@
lineno = n.Lineno
if n.Op != ODCLFIELD {
- Fatal("structfield: oops %v\n", n)
+ Fatalf("structfield: oops %v\n", n)
}
f := typ(TFIELD)
@@ -834,7 +834,7 @@
f.Type = n.Type
if f.Type == nil {
- f.Broke = 1
+ f.Broke = true
}
switch n.Val().Ctype() {
@@ -894,16 +894,16 @@
tp = &f.Down
}
- for f := t.Type; f != nil && t.Broke == 0; f = f.Down {
- if f.Broke != 0 {
- t.Broke = 1
+ for f := t.Type; f != nil && !t.Broke; f = f.Down {
+ if f.Broke {
+ t.Broke = true
}
}
uniqgen++
checkdupfields(t.Type, "field")
- if t.Broke == 0 {
+ if !t.Broke {
checkwidth(t)
}
@@ -914,11 +914,11 @@
var f *Type
t := typ(TSTRUCT)
- t.Funarg = 1
+ t.Funarg = true
for tp := &t.Type; l != nil; l = l.Next {
f = structfield(l.N)
- f.Funarg = 1
+ f.Funarg = true
// esc.c needs to find f given a PPARAM to add the tag.
if l.N.Left != nil && l.N.Left.Class == PPARAM {
@@ -929,9 +929,9 @@
tp = &f.Down
}
- for f := t.Type; f != nil && t.Broke == 0; f = f.Down {
- if f.Broke != 0 {
- t.Broke = 1
+ for f := t.Type; f != nil && !t.Broke; f = f.Down {
+ if f.Broke {
+ t.Broke = true
}
}
@@ -943,7 +943,7 @@
lineno = n.Lineno
if n.Op != ODCLFIELD {
- Fatal("interfacefield: oops %v\n", n)
+ Fatalf("interfacefield: oops %v\n", n)
}
if n.Val().Ctype() != CTxxx {
@@ -984,11 +984,11 @@
case TFORW:
Yyerror("interface type loop involving %v", n.Type)
- f.Broke = 1
+ f.Broke = true
default:
Yyerror("interface contains embedded non-interface %v", n.Type)
- f.Broke = 1
+ f.Broke = true
}
}
}
@@ -998,7 +998,7 @@
f.Type = n.Type
if f.Type == nil {
- f.Broke = 1
+ f.Broke = true
}
lineno = int32(lno)
@@ -1034,9 +1034,9 @@
}
}
- for f := t.Type; f != nil && t.Broke == 0; f = f.Down {
- if f.Broke != 0 {
- t.Broke = 1
+ for f := t.Type; f != nil && !t.Broke; f = f.Down {
+ if f.Broke {
+ t.Broke = true
}
}
@@ -1224,8 +1224,8 @@
checkdupfields(t.Type.Down.Type, "argument")
checkdupfields(t.Type.Down.Down.Type, "argument")
- if t.Type.Broke != 0 || t.Type.Down.Broke != 0 || t.Type.Down.Down.Broke != 0 {
- t.Broke = 1
+ if t.Type.Broke || t.Type.Down.Broke || t.Type.Down.Down.Broke {
+ t.Broke = true
}
if this != nil {
@@ -1233,11 +1233,11 @@
}
t.Outtuple = count(out)
t.Intuple = count(in)
- t.Outnamed = 0
+ t.Outnamed = false
if t.Outtuple > 0 && out.N.Left != nil && out.N.Left.Orig != nil {
s := out.N.Left.Orig.Sym
if s != nil && (s.Name[0] != '~' || s.Name[1] != 'r') { // ~r%d is the name invented for an unnamed result
- t.Outnamed = 1
+ t.Outnamed = true
}
}
@@ -1356,7 +1356,7 @@
func addmethod(sf *Sym, t *Type, local bool, nointerface bool) {
// get field sym
if sf == nil {
- Fatal("no method symbol")
+ Fatalf("no method symbol")
}
// get parent type sym
@@ -1383,7 +1383,7 @@
t = t.Type
}
- if t.Broke != 0 { // rely on typecheck having complained before
+ if t.Broke { // rely on typecheck having complained before
return
}
if t.Sym == nil {
@@ -1433,7 +1433,7 @@
for f := pa.Method; f != nil; f = f.Down {
d = f
if f.Etype != TFIELD {
- Fatal("addmethod: not TFIELD: %v", Tconv(f, obj.FmtLong))
+ Fatalf("addmethod: not TFIELD: %v", Tconv(f, obj.FmtLong))
}
if sf.Name != f.Sym.Name {
continue
@@ -1449,7 +1449,7 @@
// during import unexported method names should be in the type's package
if importpkg != nil && f.Sym != nil && !exportname(f.Sym.Name) && f.Sym.Pkg != structpkg {
- Fatal("imported method name %v in wrong package %s\n", Sconv(f.Sym, obj.FmtSign), structpkg.Name)
+ Fatalf("imported method name %v in wrong package %s\n", Sconv(f.Sym, obj.FmtSign), structpkg.Name)
}
if d == nil {
@@ -1466,7 +1466,7 @@
if n.Type == nil {
if nerrors == 0 {
- Fatal("funccompile missing type")
+ Fatalf("funccompile missing type")
}
return
}
@@ -1475,7 +1475,7 @@
checkwidth(n.Type)
if Curfn != nil {
- Fatal("funccompile %v inside %v", n.Func.Nname.Sym, Curfn.Func.Nname.Sym)
+ Fatalf("funccompile %v inside %v", n.Func.Nname.Sym, Curfn.Func.Nname.Sym)
}
Stksize = 0
diff --git a/src/cmd/compile/internal/gc/esc.go b/src/cmd/compile/internal/gc/esc.go
index 4c4455f..585b327 100644
--- a/src/cmd/compile/internal/gc/esc.go
+++ b/src/cmd/compile/internal/gc/esc.go
@@ -34,10 +34,10 @@
// when analyzing a set of mutually recursive functions.
type bottomUpVisitor struct {
- analyze func(*NodeList, bool)
+ analyze func([]*Node, bool)
visitgen uint32
nodeID map[*Node]uint32
- stack *NodeList
+ stack []*Node
}
// visitBottomUp invokes analyze on the ODCLFUNC nodes listed in list.
@@ -53,7 +53,7 @@
// If recursive is false, the list consists of only a single function and its closures.
// If recursive is true, the list may still contain only a single function,
// if that function is itself recursive.
-func visitBottomUp(list *NodeList, analyze func(list *NodeList, recursive bool)) {
+func visitBottomUp(list *NodeList, analyze func(list []*Node, recursive bool)) {
var v bottomUpVisitor
v.analyze = analyze
v.nodeID = make(map[*Node]uint32)
@@ -76,10 +76,7 @@
v.visitgen++
min := v.visitgen
- l := new(NodeList)
- l.Next = v.stack
- l.N = n
- v.stack = l
+ v.stack = append(v.stack, n)
min = v.visitcodelist(n.Nbody, min)
if (min == id || min == id+1) && n.Func.FCurfn == nil {
// This node is the root of a strongly connected component.
@@ -93,17 +90,19 @@
// Remove connected component from stack.
// Mark walkgen so that future visits return a large number
// so as not to affect the caller's min.
- block := v.stack
- var l *NodeList
- for l = v.stack; l.N != n; l = l.Next {
- v.nodeID[l.N] = ^uint32(0)
+ var i int
+ for i = len(v.stack) - 1; i >= 0; i-- {
+ x := v.stack[i]
+ if x == n {
+ break
+ }
+ v.nodeID[x] = ^uint32(0)
}
v.nodeID[n] = ^uint32(0)
- v.stack = l.Next
- l.Next = nil
-
+ block := v.stack[i:]
// Run escape analysis on this set of functions.
+ v.stack = v.stack[:i]
v.analyze(block, recursive)
}
@@ -323,7 +322,7 @@
return nE
}
if n.Opt() != nil {
- Fatal("nodeEscState: opt in use (%T)", n.Opt())
+ Fatalf("nodeEscState: opt in use (%T)", n.Opt())
}
nE := new(NodeEscState)
nE.Curfn = Curfn
@@ -334,7 +333,7 @@
func (e *EscState) track(n *Node) {
if Curfn == nil {
- Fatal("EscState.track: Curfn nil")
+ Fatalf("EscState.track: Curfn nil")
}
n.Esc = EscNone // until proven otherwise
nE := e.nodeEscState(n)
@@ -368,7 +367,7 @@
if e&EscMask >= EscScope {
// normalize
if e&^EscMask != 0 {
- Fatal("Escape information had unexpected return encoding bits (w/ EscScope, EscHeap, EscNever), e&EscMask=%v", e&EscMask)
+ Fatalf("Escape information had unexpected return encoding bits (w/ EscScope, EscHeap, EscNever), e&EscMask=%v", e&EscMask)
}
}
if e&EscMask > etype {
@@ -425,7 +424,7 @@
return funcSym(nE.Curfn)
}
-func escAnalyze(all *NodeList, recursive bool) {
+func escAnalyze(all []*Node, recursive bool) {
var es EscState
e := &es
e.theSink.Op = ONAME
@@ -435,16 +434,16 @@
e.nodeEscState(&e.theSink).Escloopdepth = -1
e.recursive = recursive
- for l := all; l != nil; l = l.Next {
- if l.N.Op == ODCLFUNC {
- l.N.Esc = EscFuncPlanned
+ for i := len(all) - 1; i >= 0; i-- {
+ if n := all[i]; n.Op == ODCLFUNC {
+ n.Esc = EscFuncPlanned
}
}
// flow-analyze functions
- for l := all; l != nil; l = l.Next {
- if l.N.Op == ODCLFUNC {
- escfunc(e, l.N)
+ for i := len(all) - 1; i >= 0; i-- {
+ if n := all[i]; n.Op == ODCLFUNC {
+ escfunc(e, n)
}
}
@@ -457,9 +456,9 @@
}
// for all top level functions, tag the typenodes corresponding to the param nodes
- for l := all; l != nil; l = l.Next {
- if l.N.Op == ODCLFUNC {
- esctag(e, l.N)
+ for i := len(all) - 1; i >= 0; i-- {
+ if n := all[i]; n.Op == ODCLFUNC {
+ esctag(e, n)
}
}
@@ -478,7 +477,7 @@
func escfunc(e *EscState, func_ *Node) {
// print("escfunc %N %s\n", func->nname, e->recursive?"(recursive)":"");
if func_.Esc != 1 {
- Fatal("repeat escfunc %v", func_.Func.Nname)
+ Fatalf("repeat escfunc %v", func_.Func.Nname)
}
func_.Esc = EscFuncStarted
@@ -549,7 +548,7 @@
switch n.Op {
case OLABEL:
if n.Left == nil || n.Left.Sym == nil {
- Fatal("esc:label without label: %v", Nconv(n, obj.FmtSign))
+ Fatalf("esc:label without label: %v", Nconv(n, obj.FmtSign))
}
// Walk will complain about this label being already defined, but that's not until
@@ -560,7 +559,7 @@
case OGOTO:
if n.Left == nil || n.Left.Sym == nil {
- Fatal("esc:goto without label: %v", Nconv(n, obj.FmtSign))
+ Fatalf("esc:goto without label: %v", Nconv(n, obj.FmtSign))
}
// If we come past one that's uninitialized, this must be a (harmless) forward jump
@@ -766,7 +765,7 @@
escassign(e, ll.N, lr.N)
}
if lr != nil || ll != nil {
- Fatal("esc oas2func")
+ Fatalf("esc oas2func")
}
case ORETURN:
@@ -787,7 +786,7 @@
}
if ll != nil {
- Fatal("esc return list")
+ Fatalf("esc return list")
}
// Argument could leak through recover.
@@ -949,7 +948,7 @@
switch dst.Op {
default:
Dump("dst", dst)
- Fatal("escassign: unexpected dst")
+ Fatalf("escassign: unexpected dst")
case OARRAYLIT,
OCLOSURE,
@@ -1112,7 +1111,7 @@
break
default:
- Fatal("escape mktag")
+ Fatalf("escape mktag")
}
if mask < len(tags) && tags[mask] != "" {
@@ -1239,7 +1238,7 @@
// so there is no need to check here.
if em != 0 && dsts == nil {
- Fatal("corrupt esc tag %q or messed up escretval list\n", note)
+ Fatalf("corrupt esc tag %q or messed up escretval list\n", note)
}
return em0
}
@@ -1334,7 +1333,7 @@
var fn *Node
switch n.Op {
default:
- Fatal("esccall")
+ Fatalf("esccall")
case OCALLFUNC:
fn = n.Left
@@ -1357,7 +1356,7 @@
ll := n.List
if n.List != nil && n.List.Next == nil {
a := n.List.N
- if a.Type.Etype == TSTRUCT && a.Type.Funarg != 0 { // f(g()).
+ if a.Type.Etype == TSTRUCT && a.Type.Funarg { // f(g()).
ll = e.nodeEscState(a).Escretval
}
}
@@ -1394,7 +1393,7 @@
// function in same mutually recursive group. Incorporate into flow graph.
// print("esc local fn: %N\n", fn->ntype);
if fn.Name.Defn.Esc == EscFuncUnknown || nE.Escretval != nil {
- Fatal("graph inconsistency")
+ Fatalf("graph inconsistency")
}
// set up out list on this call node
@@ -1443,7 +1442,7 @@
// Imported or completely analyzed function. Use the escape tags.
if nE.Escretval != nil {
- Fatal("esc already decorated call %v\n", Nconv(n, obj.FmtSign))
+ Fatalf("esc already decorated call %v\n", Nconv(n, obj.FmtSign))
}
if Debug['m'] > 2 {
diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go
index 66ae881..de3edfe 100644
--- a/src/cmd/compile/internal/gc/export.go
+++ b/src/cmd/compile/internal/gc/export.go
@@ -31,7 +31,7 @@
if Debug['E'] != 0 {
fmt.Printf("export symbol %v\n", n.Sym)
}
- exportlist = list(exportlist, n)
+ exportlist = append(exportlist, n)
}
func exportname(s string) bool {
@@ -79,12 +79,12 @@
}
func dumppkg(p *Pkg) {
- if p == nil || p == localpkg || p.Exported != 0 || p == builtinpkg {
+ if p == nil || p == localpkg || p.Exported || p == builtinpkg {
return
}
- p.Exported = 1
+ p.Exported = true
suffix := ""
- if p.Direct == 0 {
+ if !p.Direct {
suffix = " // indirect"
}
fmt.Fprintf(bout, "\timport %s %q%s\n", p.Name, p.Path, suffix)
@@ -124,7 +124,7 @@
if Debug['E'] != 0 {
fmt.Printf("reexport name %v\n", n.Sym)
}
- exportlist = list(exportlist, n)
+ exportlist = append(exportlist, n)
}
}
@@ -140,7 +140,7 @@
if Debug['E'] != 0 {
fmt.Printf("reexport type %v from declaration\n", t.Sym)
}
- exportlist = list(exportlist, t.Sym.Def)
+ exportlist = append(exportlist, t.Sym.Def)
}
}
@@ -154,7 +154,7 @@
if Debug['E'] != 0 {
fmt.Printf("reexport literal type %v\n", t.Sym)
}
- exportlist = list(exportlist, t.Sym.Def)
+ exportlist = append(exportlist, t.Sym.Def)
}
}
fallthrough
@@ -164,7 +164,7 @@
if Debug['E'] != 0 {
fmt.Printf("reexport literal/type %v\n", n.Sym)
}
- exportlist = list(exportlist, n)
+ exportlist = append(exportlist, n)
}
// for operations that need a type when rendered, put the type on the export list.
@@ -193,7 +193,7 @@
if Debug['E'] != 0 {
fmt.Printf("reexport type for expression %v\n", t.Sym)
}
- exportlist = list(exportlist, t.Sym.Def)
+ exportlist = append(exportlist, t.Sym.Def)
}
}
@@ -209,7 +209,7 @@
n := s.Def
typecheck(&n, Erv)
if n == nil || n.Op != OLITERAL {
- Fatal("dumpexportconst: oconst nil: %v", s)
+ Fatalf("dumpexportconst: oconst nil: %v", s)
}
t := n.Type // may or may not be specified
@@ -273,10 +273,10 @@
if t == nil {
return
}
- if t.Printed != 0 || t == Types[t.Etype] || t == bytetype || t == runetype || t == errortype {
+ if t.Printed || t == Types[t.Etype] || t == bytetype || t == runetype || t == errortype {
return
}
- t.Printed = 1
+ t.Printed = true
if t.Sym != nil && t.Etype != TFIELD {
dumppkg(t.Sym.Pkg)
@@ -371,14 +371,17 @@
fmt.Fprintf(bout, "\n")
for _, p := range pkgs {
- if p.Direct != 0 {
+ if p.Direct {
dumppkg(p)
}
}
- for l := exportlist; l != nil; l = l.Next {
- lineno = l.N.Lineno
- dumpsym(l.N.Sym)
+ // exportlist grows during iteration - cannot use range
+ for len(exportlist) > 0 {
+ n := exportlist[0]
+ exportlist = exportlist[1:]
+ lineno = n.Lineno
+ dumpsym(n.Sym)
}
fmt.Fprintf(bout, "\n$$\n")
@@ -529,7 +532,7 @@
b, err := obj.Bopenw(asmhdr)
if err != nil {
- Fatal("%v", err)
+ Fatalf("%v", err)
}
fmt.Fprintf(b, "// generated by %cg -asmhdr from package %s\n\n", Thearch.Thechar, localpkg.Name)
var n *Node
@@ -545,7 +548,7 @@
case OTYPE:
t = n.Type
- if t.Etype != TSTRUCT || t.Map != nil || t.Funarg != 0 {
+ if t.Etype != TSTRUCT || t.Map != nil || t.Funarg {
break
}
fmt.Fprintf(b, "#define %s__size %d\n", t.Sym.Name, int(t.Width))
diff --git a/src/cmd/compile/internal/gc/fmt.go b/src/cmd/compile/internal/gc/fmt.go
index c505799..08994aa 100644
--- a/src/cmd/compile/internal/gc/fmt.go
+++ b/src/cmd/compile/internal/gc/fmt.go
@@ -356,7 +356,7 @@
return "nil"
}
- return fmt.Sprintf("<ctype=%d>", v.Ctype)
+ return fmt.Sprintf("<ctype=%d>", v.Ctype())
}
/*
@@ -434,7 +434,7 @@
case FExp:
if s.Name != "" && s.Name[0] == '.' {
- Fatal("exporting synthetic symbol %s", s.Name)
+ Fatalf("exporting synthetic symbol %s", s.Name)
}
if s.Pkg != builtinpkg {
return fmt.Sprintf("@%q.%s", s.Pkg.Path, s.Name)
@@ -648,7 +648,7 @@
}
var buf bytes.Buffer
- if t.Funarg != 0 {
+ if t.Funarg {
buf.WriteString("(")
if fmtmode == FTypeId || fmtmode == FErr { // no argument names on function signature, and no "noescape"/"nosplit" tags
for t1 := t.Type; t1 != nil; t1 = t1.Down {
@@ -705,7 +705,7 @@
}
if s != nil && t.Embedded == 0 {
- if t.Funarg != 0 {
+ if t.Funarg {
name = Nconv(t.Nname, 0)
} else if flag&obj.FmtLong != 0 {
name = Sconv(s, obj.FmtShort|obj.FmtByte) // qualify non-exported names (used on structs, not on funarg)
@@ -756,7 +756,7 @@
}
if fmtmode == FExp {
- Fatal("missing %v case during export", Econv(int(t.Etype), 0))
+ Fatalf("missing %v case during export", Econv(int(t.Etype), 0))
}
// Don't know how to handle - fall back to detailed prints.
@@ -1673,7 +1673,7 @@
dumpdepth--
default:
- Fatal("unhandled %%N mode")
+ Fatalf("unhandled %%N mode")
}
flag = sf
diff --git a/src/cmd/compile/internal/gc/gen.go b/src/cmd/compile/internal/gc/gen.go
index 4ff4f7a..5d24515 100644
--- a/src/cmd/compile/internal/gc/gen.go
+++ b/src/cmd/compile/internal/gc/gen.go
@@ -62,7 +62,7 @@
n.Name.Param.Stackparam.Type = n.Type
n.Name.Param.Stackparam.Addable = true
if n.Xoffset == BADWIDTH {
- Fatal("addrescapes before param assignment")
+ Fatalf("addrescapes before param assignment")
}
n.Name.Param.Stackparam.Xoffset = n.Xoffset
fallthrough
@@ -135,7 +135,7 @@
lab.Def = n
}
} else {
- lab.Use = list(lab.Use, n)
+ lab.Use = append(lab.Use, n)
}
return lab
@@ -228,7 +228,7 @@
func cgen_proc(n *Node, proc int) {
switch n.Left.Op {
default:
- Fatal("cgen_proc: unknown call %v", Oconv(int(n.Left.Op), 0))
+ Fatalf("cgen_proc: unknown call %v", Oconv(int(n.Left.Op), 0))
case OCALLMETH:
cgen_callmeth(n.Left, proc)
@@ -252,7 +252,7 @@
}
if n.Op != ONAME {
Dump("cgen_dcl", n)
- Fatal("cgen_dcl")
+ Fatalf("cgen_dcl")
}
if n.Class&PHEAP == 0 {
@@ -362,7 +362,7 @@
Mpmovecfix(z.Val().U.(*Mpint), 0)
default:
- Fatal("clearslim called on type %v", n.Type)
+ Fatalf("clearslim called on type %v", n.Type)
}
ullmancalc(&z)
@@ -563,7 +563,7 @@
case ODOT:
if n.Xoffset == BADWIDTH {
Dump("bad width in dotoffset", n)
- Fatal("bad width in dotoffset")
+ Fatalf("bad width in dotoffset")
}
i = Dotoffset(n.Left, oary, nn)
@@ -584,7 +584,7 @@
case ODOTPTR:
if n.Xoffset == BADWIDTH {
Dump("bad width in dotoffset", n)
- Fatal("bad width in dotoffset")
+ Fatalf("bad width in dotoffset")
}
i = Dotoffset(n.Left, oary, nn)
@@ -609,7 +609,7 @@
*/
func Tempname(nn *Node, t *Type) {
if Curfn == nil {
- Fatal("no curfn for tempname")
+ Fatalf("no curfn for tempname")
}
if t == nil {
@@ -663,7 +663,7 @@
switch n.Op {
default:
- Fatal("gen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
+ Fatalf("gen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
case OCASE,
OFALL,
@@ -731,7 +731,7 @@
break
}
- lab.Used = 1
+ lab.Used = true
if lab.Breakpc == nil {
Yyerror("invalid break label %v", n.Left.Sym)
break
@@ -756,7 +756,7 @@
break
}
- lab.Used = 1
+ lab.Used = true
if lab.Continpc == nil {
Yyerror("invalid continue label %v", n.Left.Sym)
break
@@ -899,7 +899,7 @@
ret:
if Anyregalloc() != wasregalloc {
Dump("node", n)
- Fatal("registers left allocated")
+ Fatalf("registers left allocated")
}
lineno = lno
@@ -965,7 +965,7 @@
l := n.Left
if l.Op != ODOTMETH {
- Fatal("cgen_callmeth: not dotmethod: %v", l)
+ Fatalf("cgen_callmeth: not dotmethod: %v", l)
}
n2 := *n
@@ -988,26 +988,24 @@
}
func checklabels() {
- var l *NodeList
-
for lab := labellist; lab != nil; lab = lab.Link {
if lab.Def == nil {
- for l = lab.Use; l != nil; l = l.Next {
- yyerrorl(int(l.N.Lineno), "label %v not defined", lab.Sym)
+ for _, n := range lab.Use {
+ yyerrorl(int(n.Lineno), "label %v not defined", lab.Sym)
}
continue
}
- if lab.Use == nil && lab.Used == 0 {
+ if lab.Use == nil && !lab.Used {
yyerrorl(int(lab.Def.Lineno), "label %v defined and not used", lab.Sym)
continue
}
if lab.Gotopc != nil {
- Fatal("label %v never resolved", lab.Sym)
+ Fatalf("label %v never resolved", lab.Sym)
}
- for l = lab.Use; l != nil; l = l.Next {
- checkgoto(l.N, lab.Def)
+ for _, n := range lab.Use {
+ checkgoto(n, lab.Def)
}
}
}
@@ -1138,7 +1136,7 @@
nodr = *nr
if !cadable(nr) {
if nr.Ullman >= UINF && nodl.Op == OINDREG {
- Fatal("miscompile")
+ Fatalf("miscompile")
}
Igen(nr, &nodr, nil)
defer Regfree(&nodr)
@@ -1159,7 +1157,7 @@
visitComponents(nl.Type, 0, func(t *Type, offset int64) bool {
if wb && int(Simtype[t.Etype]) == Tptr && t != itable {
if ptrType != nil {
- Fatal("componentgen_wb %v", Tconv(nl.Type, 0))
+ Fatalf("componentgen_wb %v", Tconv(nl.Type, 0))
}
ptrType = t
ptrOffset = offset
@@ -1199,7 +1197,7 @@
// NOTE: Assuming little endian (signed top half at offset 4).
// We don't have any 32-bit big-endian systems.
if Thearch.Thechar != '5' && Thearch.Thechar != '8' {
- Fatal("unknown 32-bit architecture")
+ Fatalf("unknown 32-bit architecture")
}
return f(Types[TUINT32], startOffset) &&
f(Types[TINT32], startOffset+4)
@@ -1222,7 +1220,6 @@
case TINTER:
return f(itable, startOffset) &&
f(Ptrto(Types[TUINT8]), startOffset+int64(Widthptr))
- return true
case TSTRING:
return f(Ptrto(Types[TUINT8]), startOffset) &&
@@ -1256,12 +1253,12 @@
// in code introduced in CL 6932045 to fix issue #4518.
// But the test case in issue 4518 does not trigger this anymore,
// so maybe this complication is no longer needed.
- Fatal("struct not at offset 0")
+ Fatalf("struct not at offset 0")
}
for field := t.Type; field != nil; field = field.Down {
if field.Etype != TFIELD {
- Fatal("bad struct")
+ Fatalf("bad struct")
}
if !visitComponents(field.Type, startOffset+field.Width, f) {
return false
diff --git a/src/cmd/compile/internal/gc/go.go b/src/cmd/compile/internal/gc/go.go
index af8be29..424e647 100644
--- a/src/cmd/compile/internal/gc/go.go
+++ b/src/cmd/compile/internal/gc/go.go
@@ -98,7 +98,7 @@
func (v Val) Ctype() int {
switch x := v.U.(type) {
default:
- Fatal("unexpected Ctype for %T", v.U)
+ Fatalf("unexpected Ctype for %T", v.U)
panic("not reached")
case nil:
return 0
@@ -125,9 +125,9 @@
Path string // string literal used in import statement
Pathsym *Sym
Prefix string // escaped path for use in symbol table
- Imported uint8 // export data of this package was parsed
- Exported int8 // import line written in export data
- Direct int8 // imported directly
+ Imported bool // export data of this package was parsed
+ Exported bool // import line written in export data
+ Direct bool // imported directly
Safe bool // whether the package is marked as safe
Syms map[string]*Sym
}
@@ -155,18 +155,17 @@
type Type struct {
Etype uint8
Nointerface bool
- Noalg uint8
+ Noalg bool
Chan uint8
Trecur uint8 // to detect loops
- Printed uint8
+ Printed bool
Embedded uint8 // TFIELD embedded type
- Siggen uint8
- Funarg uint8 // on TSTRUCT and TFIELD
- Copyany uint8
+ Funarg bool // on TSTRUCT and TFIELD
+ Copyany bool
Local bool // created in this file
- Deferwidth uint8
- Broke uint8 // broken type definition.
- Isddd bool // TFIELD is ... argument
+ Deferwidth bool
+ Broke bool // broken type definition.
+ Isddd bool // TFIELD is ... argument
Align uint8
Haspointers uint8 // 0 unknown, 1 no, 2 yes
@@ -178,7 +177,7 @@
Thistuple int
Outtuple int
Intuple int
- Outnamed uint8
+ Outnamed bool
Method *Type
Xmethod *Type
@@ -217,10 +216,9 @@
}
type Label struct {
- Used uint8
Sym *Sym
Def *Node
- Use *NodeList
+ Use []*Node
Link *Label
// for use during gen
@@ -228,6 +226,8 @@
Labelpc *obj.Prog // pointer to code
Breakpc *obj.Prog // pointer to code
Continpc *obj.Prog // pointer to code
+
+ Used bool
}
type InitEntry struct {
@@ -586,9 +586,9 @@
var externdcl *NodeList
-var exportlist *NodeList
+var exportlist []*Node
-var importlist *NodeList // imported functions and methods with inlinable bodies
+var importlist []*Node // imported functions and methods with inlinable bodies
var funcsyms *NodeList
@@ -616,7 +616,7 @@
var block int32 // current block number
-var Hasdefer int // flag that curfn has defer statetment
+var hasdefer bool // flag that curfn has defer statement
var Curfn *Node
@@ -638,7 +638,7 @@
var Funcdepth int32
-var typecheckok int
+var typecheckok bool
var compiling_runtime int
@@ -685,8 +685,6 @@
var Disable_checknil int
-var zerosize int64
-
type Flow struct {
Prog *obj.Prog // actual instruction
P1 *Flow // predecessors of this instruction: p1,
@@ -701,7 +699,7 @@
Id int32 // sequence number in flow graph
Rpo int32 // reverse post ordering
Loop uint16 // x5 for every loop
- Refset uint8 // diagnostic generated
+ Refset bool // diagnostic generated
Data interface{} // for use by client
}
diff --git a/src/cmd/compile/internal/gc/go.y b/src/cmd/compile/internal/gc/go.y
index c6d1607..6d148e4 100644
--- a/src/cmd/compile/internal/gc/go.y
+++ b/src/cmd/compile/internal/gc/go.y
@@ -275,7 +275,7 @@
// no package statement. This allows us to test more
// than one invalid import statement in a single file.
if nerrors == 0 {
- Fatal("phase error in import");
+ Fatalf("phase error in import");
}
}
@@ -315,7 +315,7 @@
} else if importpkg.Name != $2.Name {
Yyerror("conflicting names %s and %s for package %q", importpkg.Name, $2.Name, importpkg.Path);
}
- importpkg.Direct = 1;
+ importpkg.Direct = true;
importpkg.Safe = curio.importsafe
if safemode != 0 && !curio.importsafe {
@@ -2038,7 +2038,7 @@
$2.Func.Inl = $3;
funcbody($2);
- importlist = list(importlist, $2);
+ importlist = append(importlist, $2);
if Debug['E'] > 0 {
fmt.Printf("import [%q] func %v \n", importpkg.Path, $2)
diff --git a/src/cmd/compile/internal/gc/gsubr.go b/src/cmd/compile/internal/gc/gsubr.go
index 2c575f3..7e085d9 100644
--- a/src/cmd/compile/internal/gc/gsubr.go
+++ b/src/cmd/compile/internal/gc/gsubr.go
@@ -102,7 +102,7 @@
if as == obj.ADATA || as == obj.AGLOBL {
if ddumped != 0 {
- Fatal("already dumped data")
+ Fatalf("already dumped data")
}
if dpc == nil {
dpc = Ctxt.NewProg()
@@ -132,7 +132,7 @@
func Nodreg(n *Node, t *Type, r int) {
if t == nil {
- Fatal("nodreg: t nil")
+ Fatalf("nodreg: t nil")
}
*n = Node{}
@@ -310,7 +310,7 @@
a := a // copy to let escape into Ctxt.Dconv
Debug['h'] = 1
Dump("naddr", n)
- Fatal("naddr: bad %v %v", Oconv(int(n.Op), 0), Ctxt.Dconv(a))
+ Fatalf("naddr: bad %v %v", Oconv(int(n.Op), 0), Ctxt.Dconv(a))
case OREGISTER:
a.Type = obj.TYPE_REG
@@ -346,7 +346,7 @@
case OCLOSUREVAR:
if !Curfn.Func.Needctxt {
- Fatal("closurevar without needctxt")
+ Fatalf("closurevar without needctxt")
}
a.Type = obj.TYPE_MEM
a.Reg = int16(Thearch.REGCTXT)
@@ -384,7 +384,7 @@
a.Type = obj.TYPE_MEM
switch n.Class {
default:
- Fatal("naddr: ONAME class %v %d\n", n.Sym, n.Class)
+ Fatalf("naddr: ONAME class %v %d\n", n.Sym, n.Class)
case PEXTERN:
a.Name = obj.NAME_EXTERN
@@ -410,7 +410,7 @@
}
switch n.Val().Ctype() {
default:
- Fatal("naddr: const %v", Tconv(n.Type, obj.FmtLong))
+ Fatalf("naddr: const %v", Tconv(n.Type, obj.FmtLong))
case CTFLT:
a.Type = obj.TYPE_FCONST
@@ -443,7 +443,7 @@
}
if a.Type != obj.TYPE_MEM {
a := a // copy to let escape into Ctxt.Dconv
- Fatal("naddr: OADDR %v (from %v)", Ctxt.Dconv(a), Oconv(int(n.Left.Op), 0))
+ Fatalf("naddr: OADDR %v (from %v)", Ctxt.Dconv(a), Oconv(int(n.Left.Op), 0))
}
a.Type = obj.TYPE_ADDR
@@ -511,17 +511,17 @@
var n *Node
// entire argument struct, not just one arg
- if t.Etype == TSTRUCT && t.Funarg != 0 {
+ if t.Etype == TSTRUCT && t.Funarg {
n = Nod(ONAME, nil, nil)
n.Sym = Lookup(".args")
n.Type = t
var savet Iter
first := Structfirst(&savet, &t)
if first == nil {
- Fatal("nodarg: bad struct")
+ Fatalf("nodarg: bad struct")
}
if first.Width == BADWIDTH {
- Fatal("nodarg: offset not computed for %v", t)
+ Fatalf("nodarg: offset not computed for %v", t)
}
n.Xoffset = first.Width
n.Addable = true
@@ -529,7 +529,7 @@
}
if t.Etype != TFIELD {
- Fatal("nodarg: not field %v", t)
+ Fatalf("nodarg: not field %v", t)
}
if fp == 1 {
@@ -547,7 +547,7 @@
n.Sym = t.Sym
if t.Width == BADWIDTH {
- Fatal("nodarg: offset not computed for %v", t)
+ Fatalf("nodarg: offset not computed for %v", t)
}
n.Xoffset = t.Width
n.Addable = true
@@ -574,7 +574,7 @@
n.Class = PPARAM
case 2: // offset output arg
- Fatal("shouldn't be used")
+ Fatalf("shouldn't be used")
}
n.Typecheck = 1
@@ -583,7 +583,7 @@
func Patch(p *obj.Prog, to *obj.Prog) {
if p.To.Type != obj.TYPE_BRANCH {
- Fatal("patch: not a branch")
+ Fatalf("patch: not a branch")
}
p.To.Val = to
p.To.Offset = to.Pc
@@ -591,7 +591,7 @@
func unpatch(p *obj.Prog) *obj.Prog {
if p.To.Type != obj.TYPE_BRANCH {
- Fatal("unpatch: not a branch")
+ Fatalf("unpatch: not a branch")
}
q, _ := p.To.Val.(*obj.Prog)
p.To.Val = nil
@@ -669,18 +669,18 @@
*/
func Regalloc(n *Node, t *Type, o *Node) {
if t == nil {
- Fatal("regalloc: t nil")
+ Fatalf("regalloc: t nil")
}
et := int(Simtype[t.Etype])
if Ctxt.Arch.Regsize == 4 && (et == TINT64 || et == TUINT64) {
- Fatal("regalloc 64bit")
+ Fatalf("regalloc 64bit")
}
var i int
Switch:
switch et {
default:
- Fatal("regalloc: unknown type %v", t)
+ Fatalf("regalloc: unknown type %v", t)
case TINT8, TUINT8, TINT16, TUINT16, TINT32, TUINT32, TINT64, TUINT64, TPTR32, TPTR64, TBOOL:
if o != nil && o.Op == OREGISTER {
@@ -696,7 +696,7 @@
}
Flusherrors()
Regdump()
- Fatal("out of fixed registers")
+ Fatalf("out of fixed registers")
case TFLOAT32, TFLOAT64:
if Thearch.Use387 {
@@ -716,7 +716,7 @@
}
Flusherrors()
Regdump()
- Fatal("out of floating registers")
+ Fatalf("out of floating registers")
case TCOMPLEX64, TCOMPLEX128:
Tempname(n, t)
@@ -741,7 +741,7 @@
return
}
if n.Op != OREGISTER && n.Op != OINDREG {
- Fatal("regfree: not a register")
+ Fatalf("regfree: not a register")
}
i := int(n.Reg)
if i == Thearch.REGSP {
@@ -752,12 +752,12 @@
Thearch.FREGMIN <= i && i <= Thearch.FREGMAX:
// ok
default:
- Fatal("regfree: reg out of range")
+ Fatalf("regfree: reg out of range")
}
i -= Thearch.REGMIN
if reg[i] <= 0 {
- Fatal("regfree: reg not allocated")
+ Fatalf("regfree: reg not allocated")
}
reg[i]--
if reg[i] == 0 {
@@ -772,7 +772,7 @@
Thearch.FREGMIN <= r && r <= Thearch.FREGMAX:
// ok
default:
- Fatal("reginuse: reg out of range")
+ Fatalf("reginuse: reg out of range")
}
return reg[r-Thearch.REGMIN] > 0
@@ -782,7 +782,7 @@
// so that a register can be given up but then reclaimed.
func Regrealloc(n *Node) {
if n.Op != OREGISTER && n.Op != OINDREG {
- Fatal("regrealloc: not a register")
+ Fatalf("regrealloc: not a register")
}
i := int(n.Reg)
if i == Thearch.REGSP {
@@ -793,7 +793,7 @@
Thearch.FREGMIN <= i && i <= Thearch.FREGMAX:
// ok
default:
- Fatal("regrealloc: reg out of range")
+ Fatalf("regrealloc: reg out of range")
}
i -= Thearch.REGMIN
diff --git a/src/cmd/compile/internal/gc/inl.go b/src/cmd/compile/internal/gc/inl.go
index b2eeeed..1f9b473 100644
--- a/src/cmd/compile/internal/gc/inl.go
+++ b/src/cmd/compile/internal/gc/inl.go
@@ -54,7 +54,7 @@
rcvr = rcvr.Type
}
if rcvr.Sym == nil {
- Fatal("receiver with no sym: [%v] %v (%v)", fn.Sym, Nconv(fn, obj.FmtLong), rcvr)
+ Fatalf("receiver with no sym: [%v] %v (%v)", fn.Sym, Nconv(fn, obj.FmtLong), rcvr)
}
return rcvr.Sym.Pkg
}
@@ -100,10 +100,10 @@
// fn and ->nbody will already have been typechecked.
func caninl(fn *Node) {
if fn.Op != ODCLFUNC {
- Fatal("caninl %v", fn)
+ Fatalf("caninl %v", fn)
}
if fn.Func.Nname == nil {
- Fatal("caninl no nname %v", Nconv(fn, obj.FmtSign))
+ Fatalf("caninl no nname %v", Nconv(fn, obj.FmtSign))
}
// If fn has no body (is defined outside of Go), cannot inline it.
@@ -112,7 +112,7 @@
}
if fn.Typecheck == 0 {
- Fatal("caninl on non-typechecked function %v", fn)
+ Fatalf("caninl on non-typechecked function %v", fn)
}
// can't handle ... args yet
@@ -196,10 +196,10 @@
// Call is okay if inlinable and we have the budget for the body.
case OCALLMETH:
if n.Left.Type == nil {
- Fatal("no function type for [%p] %v\n", n.Left, Nconv(n.Left, obj.FmtSign))
+ Fatalf("no function type for [%p] %v\n", n.Left, Nconv(n.Left, obj.FmtSign))
}
if n.Left.Type.Nname == nil {
- Fatal("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, obj.FmtSign))
+ Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, obj.FmtSign))
}
if n.Left.Type.Nname.Func.Inl != nil {
*budget -= int(n.Left.Type.Nname.Func.InlCost)
@@ -277,7 +277,7 @@
Curfn = fn
inlnode(&fn)
if fn != Curfn {
- Fatal("inlnode replaced curfn")
+ Fatalf("inlnode replaced curfn")
}
Curfn = savefn
}
@@ -308,7 +308,7 @@
// statements.
func inlconv2list(n *Node) *NodeList {
if n.Op != OINLCALL || n.Rlist == nil {
- Fatal("inlconv2list %v\n", Nconv(n, obj.FmtSign))
+ Fatalf("inlconv2list %v\n", Nconv(n, obj.FmtSign))
}
l := n.Rlist
@@ -470,11 +470,11 @@
// typecheck should have resolved ODOTMETH->type, whose nname points to the actual function.
if n.Left.Type == nil {
- Fatal("no function type for [%p] %v\n", n.Left, Nconv(n.Left, obj.FmtSign))
+ Fatalf("no function type for [%p] %v\n", n.Left, Nconv(n.Left, obj.FmtSign))
}
if n.Left.Type.Nname == nil {
- Fatal("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, obj.FmtSign))
+ Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, obj.FmtSign))
}
mkinlcall(np, n.Left.Type.Nname, n.Isddd)
@@ -500,7 +500,7 @@
func tinlvar(t *Type) *Node {
if t.Nname != nil && !isblank(t.Nname) {
if t.Nname.Name.Inlvar == nil {
- Fatal("missing inlvar for %v\n", t.Nname)
+ Fatalf("missing inlvar for %v\n", t.Nname)
}
return t.Nname.Name.Inlvar
}
@@ -600,13 +600,13 @@
t := getthisx(fn.Type).Type
if t != nil && t.Nname != nil && !isblank(t.Nname) && t.Nname.Name.Inlvar == nil {
- Fatal("missing inlvar for %v\n", t.Nname)
+ Fatalf("missing inlvar for %v\n", t.Nname)
}
if n.Left.Left == nil {
- Fatal("method call without receiver: %v", Nconv(n, obj.FmtSign))
+ Fatalf("method call without receiver: %v", Nconv(n, obj.FmtSign))
}
if t == nil {
- Fatal("method call unknown receiver type: %v", Nconv(n, obj.FmtSign))
+ Fatalf("method call unknown receiver type: %v", Nconv(n, obj.FmtSign))
}
as = Nod(OAS, tinlvar(t), n.Left.Left)
if as != nil {
@@ -662,17 +662,17 @@
if fn.Type.Thistuple != 0 && n.Left.Op != ODOTMETH {
// non-method call to method
if n.List == nil {
- Fatal("non-method call to method without first arg: %v", Nconv(n, obj.FmtSign))
+ Fatalf("non-method call to method without first arg: %v", Nconv(n, obj.FmtSign))
}
// append receiver inlvar to LHS.
t := getthisx(fn.Type).Type
if t != nil && t.Nname != nil && !isblank(t.Nname) && t.Nname.Name.Inlvar == nil {
- Fatal("missing inlvar for %v\n", t.Nname)
+ Fatalf("missing inlvar for %v\n", t.Nname)
}
if t == nil {
- Fatal("method call unknown receiver type: %v", Nconv(n, obj.FmtSign))
+ Fatalf("method call unknown receiver type: %v", Nconv(n, obj.FmtSign))
}
as.List = list(as.List, tinlvar(t))
ll = ll.Next // track argument count.
@@ -732,7 +732,7 @@
}
if ll != nil || t != nil {
- Fatal("arg count mismatch: %v vs %v\n", Tconv(getinargx(fn.Type), obj.FmtSharp), Hconv(n.List, obj.FmtComma))
+ Fatalf("arg count mismatch: %v vs %v\n", Tconv(getinargx(fn.Type), obj.FmtSharp), Hconv(n.List, obj.FmtComma))
}
}
@@ -956,7 +956,7 @@
m.Ninit = nil
if n.Op == OCLOSURE {
- Fatal("cannot inline function containing closure: %v", Nconv(n, obj.FmtSign))
+ Fatalf("cannot inline function containing closure: %v", Nconv(n, obj.FmtSign))
}
m.Left = inlsubst(n.Left)
diff --git a/src/cmd/compile/internal/gc/lex.go b/src/cmd/compile/internal/gc/lex.go
index d6019b3..5150e2b 100644
--- a/src/cmd/compile/internal/gc/lex.go
+++ b/src/cmd/compile/internal/gc/lex.go
@@ -237,9 +237,11 @@
obj.Flagcount("y", "debug declarations in canned imports (with -d)", &Debug['y'])
var flag_shared int
var flag_dynlink bool
+ if Thearch.Thechar == '6' || Thearch.Thechar == '5' {
+ obj.Flagcount("shared", "generate code that can be linked into a shared library", &flag_shared)
+ }
if Thearch.Thechar == '6' {
obj.Flagcount("largemodel", "generate code that assumes a large memory model", &flag_largemodel)
- obj.Flagcount("shared", "generate code that can be linked into a shared library", &flag_shared)
flag.BoolVar(&flag_dynlink, "dynlink", false, "support references to Go symbols defined in other shared libraries")
}
obj.Flagstr("cpuprofile", "write cpu profile to `file`", &cpuprofile)
@@ -305,7 +307,7 @@
Thearch.Betypeinit()
if Widthptr == 0 {
- Fatal("betypeinit failed")
+ Fatalf("betypeinit failed")
}
lexinit()
@@ -317,6 +319,7 @@
dclcontext = PEXTERN
nerrors = 0
lexlineno = 1
+ const BOM = 0xFEFF
for _, infile = range flag.Args() {
linehistpush(infile)
@@ -336,7 +339,7 @@
curio.last = 0
// Skip initial BOM if present.
- if obj.Bgetrune(curio.bin) != obj.BOM {
+ if obj.Bgetrune(curio.bin) != BOM {
obj.Bungetrune(curio.bin)
}
@@ -360,7 +363,7 @@
mkpackage(localpkg.Name) // final import not used checks
lexfini()
- typecheckok = 1
+ typecheckok = true
if Debug['f'] != 0 {
frame(1)
}
@@ -421,10 +424,10 @@
if Debug['l'] > 1 {
// Typecheck imported function bodies if debug['l'] > 1,
// otherwise lazily when used or re-exported.
- for l := importlist; l != nil; l = l.Next {
- if l.N.Func.Inl != nil {
+ for _, n := range importlist {
+ if n.Func.Inl != nil {
saveerrors()
- typecheckinl(l.N)
+ typecheckinl(n)
}
}
@@ -435,11 +438,13 @@
if Debug['l'] != 0 {
// Find functions that can be inlined and clone them before walk expands them.
- visitBottomUp(xtop, func(list *NodeList, recursive bool) {
- for l := list; l != nil; l = l.Next {
- if l.N.Op == ODCLFUNC {
- caninl(l.N)
- inlcalls(l.N)
+ visitBottomUp(xtop, func(list []*Node, recursive bool) {
+ // TODO: use a range statement here if the order does not matter
+ for i := len(list) - 1; i >= 0; i-- {
+ n := list[i]
+ if n.Op == ODCLFUNC {
+ caninl(n)
+ inlcalls(n)
}
}
})
@@ -597,11 +602,11 @@
// if there is an array.6 in the array.a library,
// want to find all of array.a, not just array.6.
file = fmt.Sprintf("%s.a", name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
file = fmt.Sprintf("%s.o", name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
return "", false
@@ -619,11 +624,11 @@
for p := idirs; p != nil; p = p.link {
file = fmt.Sprintf("%s/%s.a", p.dir, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
file = fmt.Sprintf("%s/%s.o", p.dir, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
}
@@ -640,11 +645,11 @@
}
file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.a", goroot, goos, goarch, suffixsep, suffix, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.o", goroot, goos, goarch, suffixsep, suffix, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
}
@@ -740,7 +745,7 @@
// If we already saw that package, feed a dummy statement
// to the lexer to avoid parsing export data twice.
- if importpkg.Imported != 0 {
+ if importpkg.Imported {
tag := ""
if importpkg.Safe {
tag = "safe"
@@ -751,7 +756,7 @@
return
}
- importpkg.Imported = 1
+ importpkg.Imported = true
var err error
var imp *obj.Biobuf
@@ -799,7 +804,7 @@
curio.peekc1 = 0
curio.infile = file
curio.nlsemi = 0
- typecheckok = 1
+ typecheckok = true
var c int32
for {
@@ -836,7 +841,7 @@
pushedio.bin = nil
incannedimport = 0
- typecheckok = 0
+ typecheckok = false
}
func cannedimports(file string, cp string) {
@@ -852,7 +857,7 @@
curio.nlsemi = 0
curio.importsafe = false
- typecheckok = 1
+ typecheckok = true
incannedimport = 1
}
@@ -1623,6 +1628,9 @@
}
if verb == "go:systemstack" {
+ if compiling_runtime == 0 {
+ Yyerror("//go:systemstack only allowed in runtime")
+ }
systemstack = true
return c
}
@@ -2200,7 +2208,7 @@
etype = syms[i].etype
if etype != Txxx {
if etype < 0 || etype >= len(Types) {
- Fatal("lexinit: %s bad etype", s.Name)
+ Fatalf("lexinit: %s bad etype", s.Name)
}
s1 = Pkglookup(syms[i].name, builtinpkg)
t = Types[etype]
@@ -2281,20 +2289,20 @@
rcvr.Type = typ(TFIELD)
rcvr.Type.Type = Ptrto(typ(TSTRUCT))
- rcvr.Funarg = 1
+ rcvr.Funarg = true
in := typ(TSTRUCT)
- in.Funarg = 1
+ in.Funarg = true
out := typ(TSTRUCT)
out.Type = typ(TFIELD)
out.Type.Type = Types[TSTRING]
- out.Funarg = 1
+ out.Funarg = true
f := typ(TFUNC)
*getthis(f) = rcvr
*Getoutarg(f) = out
*getinarg(f) = in
f.Thistuple = 1
f.Intuple = 0
- f.Outnamed = 0
+ f.Outnamed = false
f.Outtuple = 1
t := typ(TINTER)
t.Type = typ(TFIELD)
diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go
index d2ac813..ec74009 100644
--- a/src/cmd/compile/internal/gc/obj.go
+++ b/src/cmd/compile/internal/gc/obj.go
@@ -89,9 +89,6 @@
dumpglobls()
externdcl = tmp
- zero := Pkglookup("zerovalue", Runtimepkg)
- ggloblsym(zero, int32(zerosize), obj.DUPOK|obj.RODATA)
-
dumpdata()
obj.Writeobjdirect(Ctxt, bout)
@@ -120,7 +117,7 @@
}
if n.Type == nil {
- Fatal("external %v nil type\n", n)
+ Fatalf("external %v nil type\n", n)
}
if n.Class == PFUNC {
continue
@@ -279,7 +276,7 @@
ggloblsym(sym, int32(off), obj.NOPTR|obj.LOCAL)
if nam.Op != ONAME {
- Fatal("slicebytes %v", nam)
+ Fatalf("slicebytes %v", nam)
}
off = int(nam.Xoffset)
off = dsymptr(nam.Sym, off, sym, 0)
diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go
index 799a17e..c783d64 100644
--- a/src/cmd/compile/internal/gc/order.go
+++ b/src/cmd/compile/internal/gc/order.go
@@ -182,7 +182,7 @@
return a
}
- Fatal("ordersafeexpr %v", Oconv(int(n.Op), 0))
+ Fatalf("ordersafeexpr %v", Oconv(int(n.Op), 0))
return nil // not reached
}
@@ -336,8 +336,8 @@
// Copyret emits t1, t2, ... = n, where n is a function call,
// and then returns the list t1, t2, ....
func copyret(n *Node, order *Order) *NodeList {
- if n.Type.Etype != TSTRUCT || n.Type.Funarg == 0 {
- Fatal("copyret %v %d", n.Type, n.Left.Type.Outtuple)
+ if n.Type.Etype != TSTRUCT || !n.Type.Funarg {
+ Fatalf("copyret %v %d", n.Type, n.Left.Type.Outtuple)
}
var l1 *NodeList
@@ -403,7 +403,7 @@
func ordermapassign(n *Node, order *Order) {
switch n.Op {
default:
- Fatal("ordermapassign %v", Oconv(int(n.Op), 0))
+ Fatalf("ordermapassign %v", Oconv(int(n.Op), 0))
case OAS:
order.out = list(order.out, n)
@@ -462,7 +462,7 @@
switch n.Op {
default:
- Fatal("orderstmt %v", Oconv(int(n.Op), 0))
+ Fatalf("orderstmt %v", Oconv(int(n.Op), 0))
case OVARKILL:
order.out = list(order.out, n)
@@ -704,7 +704,7 @@
orderexpr(&n.Right, order, nil)
switch n.Type.Etype {
default:
- Fatal("orderstmt range %v", n.Type)
+ Fatalf("orderstmt range %v", n.Type)
// Mark []byte(str) range expression to reuse string backing storage.
// It is safe because the storage cannot be mutated.
@@ -773,7 +773,7 @@
var r *Node
for l := n.List; l != nil; l = l.Next {
if l.N.Op != OXCASE {
- Fatal("order select case %v", Oconv(int(l.N.Op), 0))
+ Fatalf("order select case %v", Oconv(int(l.N.Op), 0))
}
r = l.N.Left
setlineno(l.N)
@@ -781,7 +781,7 @@
// Append any new body prologue to ninit.
// The next loop will insert ninit into nbody.
if l.N.Ninit != nil {
- Fatal("order select ninit")
+ Fatalf("order select ninit")
}
if r != nil {
switch r.Op {
@@ -927,7 +927,7 @@
orderexpr(&n.Left, order, nil)
for l := n.List; l != nil; l = l.Next {
if l.N.Op != OXCASE {
- Fatal("order switch case %v", Oconv(int(l.N.Op), 0))
+ Fatalf("order switch case %v", Oconv(int(l.N.Op), 0))
}
orderexprlistinplace(l.N.List, order)
orderblock(&l.N.Nbody)
diff --git a/src/cmd/compile/internal/gc/pgen.go b/src/cmd/compile/internal/gc/pgen.go
index 33c600a..67fe8e6 100644
--- a/src/cmd/compile/internal/gc/pgen.go
+++ b/src/cmd/compile/internal/gc/pgen.go
@@ -86,7 +86,7 @@
func gvardefx(n *Node, as int) {
if n == nil {
- Fatal("gvardef nil")
+ Fatalf("gvardef nil")
}
if n.Op != ONAME {
Yyerror("gvardef %v; %v", Oconv(int(n.Op), obj.FmtSharp), n)
@@ -123,7 +123,7 @@
func gcsymdup(s *Sym) {
ls := Linksym(s)
if len(ls.R) > 0 {
- Fatal("cannot rosymdup %s with relocations", ls.Name)
+ Fatalf("cannot rosymdup %s with relocations", ls.Name)
}
ls.Name = fmt.Sprintf("gclocals·%x", md5.Sum(ls.P))
ls.Dupok = 1
@@ -274,7 +274,7 @@
dowidth(n.Type)
w = n.Type.Width
if w >= Thearch.MAXWIDTH || w < 0 {
- Fatal("bad width")
+ Fatalf("bad width")
}
Stksize += w
Stksize = Rnd(Stksize, int64(n.Type.Align))
@@ -315,7 +315,7 @@
// Ideally we wouldn't see any integer types here, but we do.
if n.Type == nil || (!Isptr[n.Type.Etype] && !Isint[n.Type.Etype] && n.Type.Etype != TUNSAFEPTR) {
Dump("checknil", n)
- Fatal("bad checknil")
+ Fatalf("bad checknil")
}
if ((Thearch.Thechar == '5' || Thearch.Thechar == '7' || Thearch.Thechar == '9') && n.Op != OREGISTER) || !n.Addable || n.Op == OLITERAL {
@@ -374,7 +374,7 @@
// set up domain for labels
clearlabels()
- if Curfn.Type.Outnamed != 0 {
+ if Curfn.Type.Outnamed {
// add clearing of the output parameters
var save Iter
t := Structfirst(&save, Getoutarg(Curfn.Type))
@@ -395,7 +395,7 @@
goto ret
}
- Hasdefer = 0
+ hasdefer = false
walk(Curfn)
if nerrors != 0 {
goto ret
@@ -498,7 +498,7 @@
// TODO: Determine when the final cgen_ret can be omitted. Perhaps always?
cgen_ret(nil)
- if Hasdefer != 0 {
+ if hasdefer {
// deferreturn pretends to have one uintptr argument.
// Reserve space for it so stack scanner is happy.
if Maxarg < int64(Widthptr) {
diff --git a/src/cmd/compile/internal/gc/plive.go b/src/cmd/compile/internal/gc/plive.go
index efaf69f..fa8bc20 100644
--- a/src/cmd/compile/internal/gc/plive.go
+++ b/src/cmd/compile/internal/gc/plive.go
@@ -95,7 +95,7 @@
func xmalloc(size uint32) interface{} {
result := (interface{})(make([]byte, size))
if result == nil {
- Fatal("malloc failed")
+ Fatalf("malloc failed")
}
return result
}
@@ -103,7 +103,7 @@
// Constructs a new basic block containing a single instruction.
func newblock(prog *obj.Prog) *BasicBlock {
if prog == nil {
- Fatal("newblock: prog cannot be nil")
+ Fatalf("newblock: prog cannot be nil")
}
result := new(BasicBlock)
result.rpo = -1
@@ -118,7 +118,7 @@
// Frees a basic block and all of its leaf data structures.
func freeblock(bb *BasicBlock) {
if bb == nil {
- Fatal("freeblock: cannot free nil")
+ Fatalf("freeblock: cannot free nil")
}
}
@@ -126,10 +126,10 @@
// to a successor of from.
func addedge(from *BasicBlock, to *BasicBlock) {
if from == nil {
- Fatal("addedge: from is nil")
+ Fatalf("addedge: from is nil")
}
if to == nil {
- Fatal("addedge: to is nil")
+ Fatalf("addedge: to is nil")
}
from.succ = append(from.succ, to)
to.pred = append(to.pred, from)
@@ -290,10 +290,10 @@
// is a call to a specific package qualified function name.
func iscall(prog *obj.Prog, name *obj.LSym) bool {
if prog == nil {
- Fatal("iscall: prog is nil")
+ Fatalf("iscall: prog is nil")
}
if name == nil {
- Fatal("iscall: function name is nil")
+ Fatalf("iscall: function name is nil")
}
if prog.As != obj.ACALL {
return false
@@ -363,14 +363,14 @@
pred := selectgo
for {
if len(pred.pred) == 0 {
- Fatal("selectgo does not have a newselect")
+ Fatalf("selectgo does not have a newselect")
}
pred = pred.pred[0]
if blockany(pred, isselectcommcasecall) {
// A select comm case block should have exactly one
// successor.
if len(pred.succ) != 1 {
- Fatal("select comm case has too many successors")
+ Fatalf("select comm case has too many successors")
}
succ = pred.succ[0]
@@ -379,7 +379,7 @@
// and the branch should lead to the select case
// statements block.
if len(succ.succ) != 2 {
- Fatal("select comm case successor has too many successors")
+ Fatalf("select comm case successor has too many successors")
}
// Add the block as a successor of the selectgo block.
@@ -429,7 +429,7 @@
Thearch.Proginfo(p)
if p.To.Type == obj.TYPE_BRANCH {
if p.To.Val == nil {
- Fatal("prog branch to nil")
+ Fatalf("prog branch to nil")
}
if p.To.Val.(*obj.Prog).Opt == nil {
p.To.Val.(*obj.Prog).Opt = newblock(p.To.Val.(*obj.Prog))
@@ -524,7 +524,7 @@
if bb.rpo == -1 {
fmt.Printf("newcfg: unreachable basic block for %v\n", bb.last)
printcfg(cfg)
- Fatal("newcfg: invalid control flow graph")
+ Fatalf("newcfg: invalid control flow graph")
}
return cfg
@@ -626,7 +626,7 @@
goto Next
}
if pos >= int32(len(vars)) || vars[pos] != from.Node {
- Fatal("bad bookkeeping in liveness %v %d", Nconv(from.Node.(*Node), 0), pos)
+ Fatalf("bad bookkeeping in liveness %v %d", Nconv(from.Node.(*Node), 0), pos)
}
if ((from.Node).(*Node)).Addrtaken {
bvset(avarinit, pos)
@@ -655,7 +655,7 @@
return
}
if pos >= int32(len(vars)) || vars[pos] != to.Node {
- Fatal("bad bookkeeping in liveness %v %d", Nconv(to.Node.(*Node), 0), pos)
+ Fatalf("bad bookkeeping in liveness %v %d", Nconv(to.Node.(*Node), 0), pos)
}
if ((to.Node).(*Node)).Addrtaken {
if prog.As != obj.AVARKILL {
@@ -718,7 +718,7 @@
// Frees the liveness structure and all of its leaf data structures.
func freeliveness(lv *Liveness) {
if lv == nil {
- Fatal("freeliveness: cannot free nil")
+ Fatalf("freeliveness: cannot free nil")
}
}
@@ -890,7 +890,7 @@
// accounts for 40% of the 6g execution time.
func onebitwalktype1(t *Type, xoffset *int64, bv Bvec) {
if t.Align > 0 && *xoffset&int64(t.Align-1) != 0 {
- Fatal("onebitwalktype1: invalid initial alignment, %v", t)
+ Fatalf("onebitwalktype1: invalid initial alignment, %v", t)
}
switch t.Etype {
@@ -919,7 +919,7 @@
TCHAN,
TMAP:
if *xoffset&int64(Widthptr-1) != 0 {
- Fatal("onebitwalktype1: invalid alignment, %v", t)
+ Fatalf("onebitwalktype1: invalid alignment, %v", t)
}
bvset(bv, int32(*xoffset/int64(Widthptr))) // pointer
*xoffset += t.Width
@@ -927,7 +927,7 @@
case TSTRING:
// struct { byte *str; intgo len; }
if *xoffset&int64(Widthptr-1) != 0 {
- Fatal("onebitwalktype1: invalid alignment, %v", t)
+ Fatalf("onebitwalktype1: invalid alignment, %v", t)
}
bvset(bv, int32(*xoffset/int64(Widthptr))) //pointer in first slot
*xoffset += t.Width
@@ -937,7 +937,7 @@
// or, when isnilinter(t)==true:
// struct { Type *type; void *data; }
if *xoffset&int64(Widthptr-1) != 0 {
- Fatal("onebitwalktype1: invalid alignment, %v", t)
+ Fatalf("onebitwalktype1: invalid alignment, %v", t)
}
bvset(bv, int32(*xoffset/int64(Widthptr))) // pointer in first slot
bvset(bv, int32(*xoffset/int64(Widthptr)+1)) // pointer in second slot
@@ -947,12 +947,12 @@
// The value of t->bound is -1 for slices types and >=0 for
// for fixed array types. All other values are invalid.
if t.Bound < -1 {
- Fatal("onebitwalktype1: invalid bound, %v", t)
+ Fatalf("onebitwalktype1: invalid bound, %v", t)
}
if Isslice(t) {
// struct { byte *array; uintgo len; uintgo cap; }
if *xoffset&int64(Widthptr-1) != 0 {
- Fatal("onebitwalktype1: invalid TARRAY alignment, %v", t)
+ Fatalf("onebitwalktype1: invalid TARRAY alignment, %v", t)
}
bvset(bv, int32(*xoffset/int64(Widthptr))) // pointer in first slot (BitsPointer)
*xoffset += t.Width
@@ -975,7 +975,7 @@
*xoffset += t.Width - o
default:
- Fatal("onebitwalktype1: unexpected type, %v", t)
+ Fatalf("onebitwalktype1: unexpected type, %v", t)
}
}
@@ -1346,7 +1346,7 @@
if pos < 0 {
// the first block we encounter should have the ATEXT so
// at no point should pos ever be less than zero.
- Fatal("livenessepilogue")
+ Fatalf("livenessepilogue")
}
bvcopy(livein, bb.liveout)
@@ -1685,15 +1685,13 @@
for j = 0; j < len(lv.vars); j++ {
n = lv.vars[j]
if islive(n, args, locals) {
- tmp9 := printed
- printed++
- if tmp9 != 0 {
+ if printed != 0 {
fmt.Printf(",")
}
fmt.Printf("%v", n)
+ printed++
}
}
-
fmt.Printf("\n")
}
diff --git a/src/cmd/compile/internal/gc/popt.go b/src/cmd/compile/internal/gc/popt.go
index 4fc562c..0b3bde5 100644
--- a/src/cmd/compile/internal/gc/popt.go
+++ b/src/cmd/compile/internal/gc/popt.go
@@ -306,11 +306,11 @@
if p.To.Type == obj.TYPE_BRANCH {
if p.To.Val == nil {
- Fatal("pnil %v", p)
+ Fatalf("pnil %v", p)
}
f1 = p.To.Val.(*obj.Prog).Opt.(*Flow)
if f1 == nil {
- Fatal("fnil %v / %v", p, p.To.Val.(*obj.Prog))
+ Fatalf("fnil %v / %v", p, p.To.Val.(*obj.Prog))
}
if f1 == f {
//fatal("self loop %v", p);
@@ -380,7 +380,7 @@
for rpo1 < rpo2 {
t = idom[rpo2]
if t >= rpo2 {
- Fatal("bad idom")
+ Fatalf("bad idom")
}
rpo2 = t
}
@@ -435,7 +435,7 @@
d := postorder(g.Start, rpo2r, 0)
nr := int32(g.Num)
if d > nr {
- Fatal("too many reg nodes %d %d", d, nr)
+ Fatalf("too many reg nodes %d %d", d, nr)
}
nr = d
var r1 *Flow
@@ -605,7 +605,7 @@
for f := g.Start; f != nil; f = f.Link {
p := f.Prog
if p.From.Node != nil && ((p.From.Node).(*Node)).Opt() != nil && p.To.Node != nil && ((p.To.Node).(*Node)).Opt() != nil {
- Fatal("double node %v", p)
+ Fatalf("double node %v", p)
}
v = nil
n, _ = p.From.Node.(*Node)
@@ -655,7 +655,7 @@
fmt.Printf("drop write-only %v\n", v.node.Sym)
}
} else {
- Fatal("temp used and not set: %v", p)
+ Fatalf("temp used and not set: %v", p)
}
nkill++
continue
diff --git a/src/cmd/compile/internal/gc/racewalk.go b/src/cmd/compile/internal/gc/racewalk.go
index f53e8ec..9301d87 100644
--- a/src/cmd/compile/internal/gc/racewalk.go
+++ b/src/cmd/compile/internal/gc/racewalk.go
@@ -116,7 +116,7 @@
}
setlineno(n)
if init == nil {
- Fatal("racewalk: bad init list")
+ Fatalf("racewalk: bad init list")
}
if init == &n.Ninit {
// If init == &n->ninit and n->ninit is non-nil,
@@ -136,7 +136,7 @@
switch n.Op {
default:
- Fatal("racewalk: unknown node type %v", Oconv(int(n.Op), 0))
+ Fatalf("racewalk: unknown node type %v", Oconv(int(n.Op), 0))
case OAS, OASWB, OAS2FUNC:
racewalknode(&n.Left, init, 1, 0)
diff --git a/src/cmd/compile/internal/gc/range.go b/src/cmd/compile/internal/gc/range.go
index 26f05d9..dbfd674 100644
--- a/src/cmd/compile/internal/gc/range.go
+++ b/src/cmd/compile/internal/gc/range.go
@@ -165,7 +165,7 @@
var init *NodeList
switch t.Etype {
default:
- Fatal("walkrange")
+ Fatalf("walkrange")
// Lower n into runtime·memclr if possible, for
// fast zeroing of slices and arrays (issue 5373).
diff --git a/src/cmd/compile/internal/gc/reflect.go b/src/cmd/compile/internal/gc/reflect.go
index 1ac4a03..f579ef8 100644
--- a/src/cmd/compile/internal/gc/reflect.go
+++ b/src/cmd/compile/internal/gc/reflect.go
@@ -192,7 +192,7 @@
field = append(field, ovf)
// link up fields
- bucket.Noalg = 1
+ bucket.Noalg = true
bucket.Local = t.Local
bucket.Type = field[0]
for n := int32(0); n < int32(len(field)-1); n++ {
@@ -232,7 +232,7 @@
field[7] = makefield("overflow", Types[TUNSAFEPTR])
h := typ(TSTRUCT)
- h.Noalg = 1
+ h.Noalg = true
h.Local = t.Local
h.Type = field[0]
for n := int32(0); n < int32(len(field)-1); n++ {
@@ -284,7 +284,7 @@
// build iterator struct holding the above fields
i := typ(TSTRUCT)
- i.Noalg = 1
+ i.Noalg = true
i.Type = field[0]
for n := int32(0); n < int32(len(field)-1); n++ {
field[n].Down = field[n+1]
@@ -364,13 +364,13 @@
var method *Sym
for f := mt.Xmethod; f != nil; f = f.Down {
if f.Etype != TFIELD {
- Fatal("methods: not field %v", f)
+ Fatalf("methods: not field %v", f)
}
if f.Type.Etype != TFUNC || f.Type.Thistuple == 0 {
- Fatal("non-method on %v method %v %v\n", mt, f.Sym, f)
+ Fatalf("non-method on %v method %v %v\n", mt, f.Sym, f)
}
if getthisx(f.Type).Type == nil {
- Fatal("receiver with no type on %v method %v %v\n", mt, f.Sym, f)
+ Fatalf("receiver with no type on %v method %v %v\n", mt, f.Sym, f)
}
if f.Nointerface {
continue
@@ -401,7 +401,7 @@
a.name = method.Name
if !exportname(method.Name) {
if method.Pkg == nil {
- Fatal("methods: missing package")
+ Fatalf("methods: missing package")
}
a.pkg = method.Pkg
}
@@ -445,7 +445,7 @@
var last *Sig
for f := t.Type; f != nil; f = f.Down {
if f.Etype != TFIELD {
- Fatal("imethods: not field")
+ Fatalf("imethods: not field")
}
if f.Type.Etype != TFUNC || f.Sym == nil {
continue
@@ -455,7 +455,7 @@
a.name = method.Name
if !exportname(method.Name) {
if method.Pkg == nil {
- Fatal("imethods: missing package")
+ Fatalf("imethods: missing package")
}
a.pkg = method.Pkg
}
@@ -465,7 +465,7 @@
a.type_ = methodfunc(f.Type, nil)
if last != nil && sigcmp(last, a) >= 0 {
- Fatal("sigcmp vs sortinter %s %s", last.name, a.name)
+ Fatalf("sigcmp vs sortinter %s %s", last.name, a.name)
}
if last == nil {
all = a
@@ -707,7 +707,7 @@
ret = true
case TFIELD:
- Fatal("haspointers: unexpected type, %v", t)
+ Fatalf("haspointers: unexpected type, %v", t)
}
t.Haspointers = 1 + uint8(obj.Bool2int(ret))
@@ -758,7 +758,7 @@
return lastPtrField.Width + typeptrdata(lastPtrField.Type)
default:
- Fatal("typeptrdata: unexpected type, %v", t)
+ Fatalf("typeptrdata: unexpected type, %v", t)
return 0
}
}
@@ -772,7 +772,7 @@
func dcommontype(s *Sym, ot int, t *Type) int {
if ot != 0 {
- Fatal("dcommontype %d", ot)
+ Fatalf("dcommontype %d", ot)
}
sizeofAlg := 2 * Widthptr
@@ -794,20 +794,8 @@
sptr = weaktypesym(tptr)
}
- // All (non-reflect-allocated) Types share the same zero object.
- // Each place in the compiler where a pointer to the zero object
- // might be returned by a runtime call (map access return value,
- // 2-arg type cast) declares the size of the zerovalue it needs.
- // The linker magically takes the max of all the sizes.
- zero := Pkglookup("zerovalue", Runtimepkg)
-
gcsym, useGCProg, ptrdata := dgcsym(t)
- // We use size 0 here so we get the pointer to the zero value,
- // but don't allocate space for the zero value unless we need it.
- // TODO: how do we get this symbol into bss? We really want
- // a read-only bss, but I don't think such a thing exists.
-
// ../../pkg/reflect/type.go:/^type.commonType
// actual type structure
// type commonType struct {
@@ -823,7 +811,6 @@
// string *string
// *extraType
// ptrToThis *Type
- // zero unsafe.Pointer
// }
ot = duintptr(s, ot, uint64(t.Width))
ot = duintptr(s, ot, uint64(ptrdata))
@@ -838,7 +825,7 @@
i = 1
}
if i&(i-1) != 0 {
- Fatal("invalid alignment %d for %v", t.Align, t)
+ Fatalf("invalid alignment %d for %v", t.Align, t)
}
ot = duint8(s, ot, t.Align) // align
ot = duint8(s, ot, t.Align) // fieldAlign
@@ -876,7 +863,6 @@
ot += Widthptr
ot = dsymptr(s, ot, sptr, 0) // ptrto type
- ot = dsymptr(s, ot, zero, 0) // ptr to zero value
return ot
}
@@ -918,7 +904,7 @@
func typenamesym(t *Type) *Sym {
if t == nil || (Isptr[t.Etype] && t.Type == nil) || isideal(t) {
- Fatal("typename %v", t)
+ Fatalf("typename %v", t)
}
s := typesym(t)
if s.Def == nil {
@@ -991,7 +977,7 @@
case TARRAY:
if Isslice(t) {
- Fatal("slice can't be a map key: %v", t)
+ Fatalf("slice can't be a map key: %v", t)
}
return isreflexive(t.Type)
@@ -1005,7 +991,7 @@
return true
default:
- Fatal("bad type for map key: %v", t)
+ Fatalf("bad type for map key: %v", t)
return false
}
}
@@ -1019,7 +1005,7 @@
}
if isideal(t) {
- Fatal("dtypesym %v", t)
+ Fatalf("dtypesym %v", t)
}
s := typesym(t)
@@ -1059,7 +1045,7 @@
switch t.Etype {
default:
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
case TARRAY:
if t.Bound >= 0 {
@@ -1071,7 +1057,7 @@
t2.Bound = -1 // slice
s2 := dtypesym(t2)
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = dsymptr(s, ot, s1, 0)
ot = dsymptr(s, ot, s2, 0)
ot = duintptr(s, ot, uint64(t.Bound))
@@ -1080,7 +1066,7 @@
s1 := dtypesym(t.Type)
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = dsymptr(s, ot, s1, 0)
}
@@ -1089,7 +1075,7 @@
s1 := dtypesym(t.Type)
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = dsymptr(s, ot, s1, 0)
ot = duintptr(s, ot, uint64(t.Chan))
@@ -1108,7 +1094,7 @@
}
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = duint8(s, ot, uint8(obj.Bool2int(isddd)))
// two slice headers: in and out.
@@ -1147,7 +1133,7 @@
// ../../runtime/type.go:/InterfaceType
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = dsymptr(s, ot, s, ot+Widthptr+2*Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
@@ -1167,7 +1153,7 @@
s3 := dtypesym(mapbucket(t))
s4 := dtypesym(hmap(t))
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = dsymptr(s, ot, s1, 0)
ot = dsymptr(s, ot, s2, 0)
ot = dsymptr(s, ot, s3, 0)
@@ -1203,7 +1189,7 @@
s1 := dtypesym(t.Type)
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = dsymptr(s, ot, s1, 0)
// ../../runtime/type.go:/StructType
@@ -1217,7 +1203,7 @@
}
ot = dcommontype(s, ot, t)
- xt = ot - 3*Widthptr
+ xt = ot - 2*Widthptr
ot = dsymptr(s, ot, s, ot+Widthptr+2*Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
@@ -1307,7 +1293,7 @@
// generate import strings for imported packages
for _, p := range pkgs {
- if p.Direct != 0 {
+ if p.Direct {
dimportpath(p)
}
}
@@ -1505,7 +1491,7 @@
func dgcprog(t *Type) (*Sym, int64) {
dowidth(t)
if t.Width == BADWIDTH {
- Fatal("dgcprog: %v badwidth", t)
+ Fatalf("dgcprog: %v badwidth", t)
}
sym := typesymprefix(".gcprog", t)
var p GCProg
@@ -1514,7 +1500,7 @@
offset := p.w.BitIndex() * int64(Widthptr)
p.end()
if ptrdata := typeptrdata(t); offset < ptrdata || offset > t.Width {
- Fatal("dgcprog: %v: offset=%d but ptrdata=%d size=%d", t, offset, ptrdata, t.Width)
+ Fatalf("dgcprog: %v: offset=%d but ptrdata=%d size=%d", t, offset, ptrdata, t.Width)
}
return sym, offset
}
@@ -1561,7 +1547,7 @@
}
switch t.Etype {
default:
- Fatal("GCProg.emit: unexpected type %v", t)
+ Fatalf("GCProg.emit: unexpected type %v", t)
case TSTRING:
p.w.Ptr(offset / int64(Widthptr))
@@ -1577,7 +1563,7 @@
}
if t.Bound == 0 {
// should have been handled by haspointers check above
- Fatal("GCProg.emit: empty array")
+ Fatalf("GCProg.emit: empty array")
}
// Flatten array-of-array-of-array to just a big array by multiplying counts.
diff --git a/src/cmd/compile/internal/gc/reg.go b/src/cmd/compile/internal/gc/reg.go
index 0fa0535..b3e9621 100644
--- a/src/cmd/compile/internal/gc/reg.go
+++ b/src/cmd/compile/internal/gc/reg.go
@@ -351,7 +351,7 @@
}
node = node.Orig
if node.Orig != node {
- Fatal("%v: bad node", Ctxt.Dconv(a))
+ Fatalf("%v: bad node", Ctxt.Dconv(a))
}
if node.Sym == nil || node.Sym.Name[0] == '.' {
return zbits
@@ -360,7 +360,7 @@
o := a.Offset
w := a.Width
if w < 0 {
- Fatal("bad width %d for %v", w, Ctxt.Dconv(a))
+ Fatalf("bad width %d for %v", w, Ctxt.Dconv(a))
}
flag := 0
@@ -396,7 +396,7 @@
if nvar >= NVAR {
if Debug['w'] > 1 && node != nil {
- Fatal("variable not optimized: %v", Nconv(node, obj.FmtSharp))
+ Fatalf("variable not optimized: %v", Nconv(node, obj.FmtSharp))
}
if Debug['v'] > 0 {
Warn("variable not optimized: %v", Nconv(node, obj.FmtSharp))
@@ -486,7 +486,7 @@
//
// Disable registerization for results if using defer, because the deferred func
// might recover and return, causing the current values to be used.
- if node.Class == PEXTERN || (Hasdefer != 0 && node.Class == PPARAMOUT) {
+ if node.Class == PEXTERN || (hasdefer && node.Class == PPARAMOUT) {
v.addr = 1
}
@@ -655,7 +655,7 @@
r.regno = 0
switch v.etype {
default:
- Fatal("unknown etype %d/%v", Bitno(b), Econv(int(v.etype), 0))
+ Fatalf("unknown etype %d/%v", Bitno(b), Econv(int(v.etype), 0))
case TINT8,
TUINT8,
@@ -1120,7 +1120,7 @@
// Currently we never generate three register forms.
// If we do, this will need to change.
if p.From3Type() != obj.TYPE_NONE {
- Fatal("regopt not implemented for from3")
+ Fatalf("regopt not implemented for from3")
}
bit = mkvar(f, &p.To)
@@ -1289,12 +1289,12 @@
for z := 0; z < BITS; z++ {
bit.b[z] = (r.refahead.b[z] | r.calahead.b[z]) &^ (externs.b[z] | params.b[z] | addrs.b[z] | consts.b[z])
}
- if bany(&bit) && f.Refset == 0 {
+ if bany(&bit) && !f.Refset {
// should never happen - all variables are preset
if Debug['w'] != 0 {
fmt.Printf("%v: used and not set: %v\n", f.Prog.Line(), &bit)
}
- f.Refset = 1
+ f.Refset = true
}
}
@@ -1309,11 +1309,11 @@
for z := 0; z < BITS; z++ {
bit.b[z] = r.set.b[z] &^ (r.refahead.b[z] | r.calahead.b[z] | addrs.b[z])
}
- if bany(&bit) && f.Refset == 0 {
+ if bany(&bit) && !f.Refset {
if Debug['w'] != 0 {
fmt.Printf("%v: set and not used: %v\n", f.Prog.Line(), &bit)
}
- f.Refset = 1
+ f.Refset = true
Thearch.Excise(f)
}
@@ -1472,7 +1472,7 @@
}
}
- Fatal("bad in bnum")
+ Fatalf("bad in bnum")
return 0
}
@@ -1499,10 +1499,10 @@
}
// Bitno reports the lowest index of a 1 bit in b.
-// It calls Fatal if there is no 1 bit.
+// It calls Fatalf if there is no 1 bit.
func Bitno(b uint64) int {
if b == 0 {
- Fatal("bad in bitno")
+ Fatalf("bad in bitno")
}
n := 0
if b&(1<<32-1) == 0 {
diff --git a/src/cmd/compile/internal/gc/select.go b/src/cmd/compile/internal/gc/select.go
index db20778..83f53c1 100644
--- a/src/cmd/compile/internal/gc/select.go
+++ b/src/cmd/compile/internal/gc/select.go
@@ -20,7 +20,7 @@
ncase = l.N
setlineno(ncase)
if ncase.Op != OXCASE {
- Fatal("typecheckselect %v", Oconv(int(ncase.Op), 0))
+ Fatalf("typecheckselect %v", Oconv(int(ncase.Op), 0))
}
if ncase.List == nil {
@@ -90,7 +90,7 @@
func walkselect(sel *Node) {
if sel.List == nil && sel.Xoffset != 0 {
- Fatal("double walkselect") // already rewrote
+ Fatalf("double walkselect") // already rewrote
}
lno := int(setlineno(sel))
@@ -122,7 +122,7 @@
var ch *Node
switch n.Op {
default:
- Fatal("select %v", Oconv(int(n.Op), 0))
+ Fatalf("select %v", Oconv(int(n.Op), 0))
// ok already
case OSEND:
@@ -218,7 +218,7 @@
r.Ninit = cas.Ninit
switch n.Op {
default:
- Fatal("select %v", Oconv(int(n.Op), 0))
+ Fatalf("select %v", Oconv(int(n.Op), 0))
// if selectnbsend(c, v) { body } else { default body }
case OSEND:
@@ -284,7 +284,7 @@
} else {
switch n.Op {
default:
- Fatal("select %v", Oconv(int(n.Op), 0))
+ Fatalf("select %v", Oconv(int(n.Op), 0))
// selectsend(sel *byte, hchan *chan any, elem *any) (selected bool);
case OSEND:
@@ -335,7 +335,7 @@
sudog.List = list(sudog.List, Nod(ODCLFIELD, newname(Lookup("nrelease")), typenod(Types[TINT32])))
sudog.List = list(sudog.List, Nod(ODCLFIELD, newname(Lookup("waitlink")), typenod(Ptrto(Types[TUINT8]))))
typecheck(&sudog, Etype)
- sudog.Type.Noalg = 1
+ sudog.Type.Noalg = true
sudog.Type.Local = true
scase := Nod(OTSTRUCT, nil, nil)
@@ -347,7 +347,7 @@
scase.List = list(scase.List, Nod(ODCLFIELD, newname(Lookup("receivedp")), typenod(Ptrto(Types[TUINT8]))))
scase.List = list(scase.List, Nod(ODCLFIELD, newname(Lookup("releasetime")), typenod(Types[TUINT64])))
typecheck(&scase, Etype)
- scase.Type.Noalg = 1
+ scase.Type.Noalg = true
scase.Type.Local = true
sel := Nod(OTSTRUCT, nil, nil)
@@ -362,7 +362,7 @@
arr = Nod(OTARRAY, Nodintconst(int64(size)), typenod(Types[TUINT16]))
sel.List = list(sel.List, Nod(ODCLFIELD, newname(Lookup("pollorderarr")), arr))
typecheck(&sel, Etype)
- sel.Type.Noalg = 1
+ sel.Type.Noalg = true
sel.Type.Local = true
return sel.Type
diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go
index ce95839..a6eeaf0 100644
--- a/src/cmd/compile/internal/gc/sinit.go
+++ b/src/cmd/compile/internal/gc/sinit.go
@@ -19,7 +19,7 @@
)
var (
- initlist *NodeList
+ initlist []*Node
initplans map[*Node]*InitPlan
inittemps = make(map[*Node]*Node)
)
@@ -47,15 +47,12 @@
}
switch n.Class {
case PEXTERN, PFUNC:
- break
-
default:
if isblank(n) && n.Name.Curfn == nil && n.Name.Defn != nil && n.Name.Defn.Initorder == InitNotStarted {
// blank names initialization is part of init() but not
// when they are inside a function.
break
}
-
return
}
@@ -72,90 +69,43 @@
// Conversely, if there exists an initialization cycle involving
// a variable in the program, the tree walk will reach a cycle
// involving that variable.
- var nv *Node
if n.Class != PFUNC {
- nv = n
- goto foundinitloop
+ foundinitloop(n, n)
}
- for l := initlist; l.N != n; l = l.Next {
- if l.N.Class != PFUNC {
- nv = l.N
- goto foundinitloop
+ for i := len(initlist) - 1; i >= 0; i-- {
+ x := initlist[i]
+ if x == n {
+ break
+ }
+ if x.Class != PFUNC {
+ foundinitloop(n, x)
}
}
// The loop involves only functions, ok.
return
-
- // if there have already been errors printed,
- // those errors probably confused us and
- // there might not be a loop. let the user
- // fix those first.
- foundinitloop:
- Flusherrors()
-
- if nerrors > 0 {
- errorexit()
- }
-
- // There is a loop involving nv. We know about
- // n and initlist = n1 <- ... <- nv <- ... <- n <- ...
- fmt.Printf("%v: initialization loop:\n", nv.Line())
-
- // Build back pointers in initlist.
- for l := initlist; l != nil; l = l.Next {
- if l.Next != nil {
- l.Next.End = l
- }
- }
-
- // Print nv -> ... -> n1 -> n.
- var l *NodeList
- for l = initlist; l.N != nv; l = l.Next {
- }
- for ; l != nil; l = l.End {
- fmt.Printf("\t%v %v refers to\n", l.N.Line(), l.N.Sym)
- }
-
- // Print n -> ... -> nv.
- for l = initlist; l.N != n; l = l.Next {
- }
- for ; l.N != nv; l = l.End {
- fmt.Printf("\t%v %v refers to\n", l.N.Line(), l.N.Sym)
- }
- fmt.Printf("\t%v %v\n", nv.Line(), nv.Sym)
- errorexit()
}
// reached a new unvisited node.
n.Initorder = InitPending
-
- l := new(NodeList)
- if l == nil {
- Flusherrors()
- Yyerror("out of memory")
- errorexit()
- }
-
- l.Next = initlist
- l.N = n
- l.End = nil
- initlist = l
+ initlist = append(initlist, n)
// make sure that everything n depends on is initialized.
// n->defn is an assignment to n
if defn := n.Name.Defn; defn != nil {
switch defn.Op {
default:
- goto bad
+ Dump("defn", defn)
+ Fatalf("init1: bad defn")
case ODCLFUNC:
init2list(defn.Nbody, out)
case OAS:
if defn.Left != n {
- goto bad
+ Dump("defn", defn)
+ Fatalf("init1: bad defn")
}
if isblank(defn.Left) && candiscard(defn.Right) {
defn.Op = OEMPTY
@@ -190,18 +140,51 @@
}
}
- l = initlist
- initlist = l.Next
- if l.N != n {
- Fatal("bad initlist")
+ last := len(initlist) - 1
+ if initlist[last] != n {
+ Fatalf("bad initlist %v", initlist)
}
+ initlist[last] = nil // allow GC
+ initlist = initlist[:last]
n.Initorder = InitDone
return
+}
-bad:
- Dump("defn", n.Name.Defn)
- Fatal("init1: bad defn")
+// foundinitloop prints an init loop error and exits.
+func foundinitloop(node, visited *Node) {
+ // If there have already been errors printed,
+ // those errors probably confused us and
+ // there might not be a loop. Let the user
+ // fix those first.
+ Flusherrors()
+ if nerrors > 0 {
+ errorexit()
+ }
+
+ // Find the index of node and visited in the initlist.
+ var nodeindex, visitedindex int
+ for ; initlist[nodeindex] != node; nodeindex++ {
+ }
+ for ; initlist[visitedindex] != visited; visitedindex++ {
+ }
+
+ // There is a loop involving visited. We know about node and
+ // initlist = n1 <- ... <- visited <- ... <- node <- ...
+ fmt.Printf("%v: initialization loop:\n", visited.Line())
+
+ // Print visited -> ... -> n1 -> node.
+ for _, n := range initlist[visitedindex:] {
+ fmt.Printf("\t%v %v refers to\n", n.Line(), n.Sym)
+ }
+
+ // Print node -> ... -> visited.
+ for _, n := range initlist[nodeindex:visitedindex] {
+ fmt.Printf("\t%v %v refers to\n", n.Line(), n.Sym)
+ }
+
+ fmt.Printf("\t%v %v\n", visited.Line(), visited.Sym)
+ errorexit()
}
// recurse over n, doing init1 everywhere.
@@ -211,7 +194,7 @@
}
if n.Op == ONAME && n.Ninit != nil {
- Fatal("name %v with ninit: %v\n", n.Sym, Nconv(n, obj.FmtSign))
+ Fatalf("name %v with ninit: %v\n", n.Sym, Nconv(n, obj.FmtSign))
}
init1(n, out)
@@ -271,7 +254,7 @@
*/
func staticinit(n *Node, out **NodeList) bool {
if n.Op != ONAME || n.Class != PEXTERN || n.Name.Defn == nil || n.Name.Defn.Op != OAS {
- Fatal("staticinit")
+ Fatalf("staticinit")
}
lineno = n.Lineno
@@ -607,7 +590,7 @@
for nl := n.List; nl != nil; nl = nl.Next {
r = nl.N
if r.Op != OKEY {
- Fatal("structlit: rhs not OKEY: %v", r)
+ Fatalf("structlit: rhs not OKEY: %v", r)
}
index = r.Left
value = r.Right
@@ -654,7 +637,7 @@
if pass == 1 {
walkexpr(&a, init) // add any assignments in r to top
if a.Op != OAS {
- Fatal("structlit: not as")
+ Fatalf("structlit: not as")
}
a.Dodata = 2
} else {
@@ -675,7 +658,7 @@
for l := n.List; l != nil; l = l.Next {
r = l.N
if r.Op != OKEY {
- Fatal("arraylit: rhs not OKEY: %v", r)
+ Fatalf("arraylit: rhs not OKEY: %v", r)
}
index = r.Left
value = r.Right
@@ -722,7 +705,7 @@
if pass == 1 {
walkexpr(&a, init)
if a.Op != OAS {
- Fatal("arraylit: not as")
+ Fatalf("arraylit: not as")
}
a.Dodata = 2
} else {
@@ -851,7 +834,7 @@
for l := n.List; l != nil; l = l.Next {
r = l.N
if r.Op != OKEY {
- Fatal("slicelit: rhs not OKEY: %v", r)
+ Fatalf("slicelit: rhs not OKEY: %v", r)
}
index = r.Left
value = r.Right
@@ -909,7 +892,7 @@
r = l.N
if r.Op != OKEY {
- Fatal("maplit: rhs not OKEY: %v", r)
+ Fatalf("maplit: rhs not OKEY: %v", r)
}
index = r.Left
value = r.Right
@@ -960,7 +943,7 @@
r = l.N
if r.Op != OKEY {
- Fatal("maplit: rhs not OKEY: %v", r)
+ Fatalf("maplit: rhs not OKEY: %v", r)
}
index = r.Left
value = r.Right
@@ -1031,7 +1014,7 @@
r = l.N
if r.Op != OKEY {
- Fatal("maplit: rhs not OKEY: %v", r)
+ Fatalf("maplit: rhs not OKEY: %v", r)
}
index = r.Left
value = r.Right
@@ -1083,11 +1066,11 @@
t := n.Type
switch n.Op {
default:
- Fatal("anylit: not lit")
+ Fatalf("anylit: not lit")
case OPTRLIT:
if !Isptr[t.Etype] {
- Fatal("anylit: not ptr")
+ Fatalf("anylit: not ptr")
}
var r *Node
@@ -1113,7 +1096,7 @@
case OSTRUCTLIT:
if t.Etype != TSTRUCT {
- Fatal("anylit: not struct")
+ Fatalf("anylit: not struct")
}
if simplename(var_) && count(n.List) > 4 {
@@ -1153,7 +1136,7 @@
case OARRAYLIT:
if t.Etype != TARRAY {
- Fatal("anylit: not array")
+ Fatalf("anylit: not array")
}
if t.Bound < 0 {
slicelit(ctxt, n, var_, init)
@@ -1197,7 +1180,7 @@
case OMAPLIT:
if t.Etype != TMAP {
- Fatal("anylit: not map")
+ Fatalf("anylit: not map")
}
maplit(ctxt, n, var_, init)
}
@@ -1305,14 +1288,14 @@
initplans[n] = p
switch n.Op {
default:
- Fatal("initplan")
+ Fatalf("initplan")
case OARRAYLIT:
var a *Node
for l := n.List; l != nil; l = l.Next {
a = l.N
if a.Op != OKEY || !Smallintconst(a.Left) {
- Fatal("initplan arraylit")
+ Fatalf("initplan arraylit")
}
addvalue(p, n.Type.Type.Width*Mpgetfix(a.Left.Val().U.(*Mpint)), nil, a.Right)
}
@@ -1322,7 +1305,7 @@
for l := n.List; l != nil; l = l.Next {
a = l.N
if a.Op != OKEY || a.Left.Type == nil {
- Fatal("initplan structlit")
+ Fatalf("initplan structlit")
}
addvalue(p, a.Left.Type.Width, nil, a.Right)
}
@@ -1332,7 +1315,7 @@
for l := n.List; l != nil; l = l.Next {
a = l.N
if a.Op != OKEY {
- Fatal("initplan maplit")
+ Fatalf("initplan maplit")
}
addvalue(p, -1, a.Left, a.Right)
}
@@ -1378,7 +1361,7 @@
switch n.Val().Ctype() {
default:
Dump("unexpected literal", n)
- Fatal("iszero")
+ Fatalf("iszero")
case CTNIL:
return true
@@ -1557,7 +1540,7 @@
no:
if n.Dodata == 2 {
Dump("\ngen_as_init", n)
- Fatal("gen_as_init couldnt make data statement")
+ Fatalf("gen_as_init couldnt make data statement")
}
return false
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go
index a554a1d..96d6204 100644
--- a/src/cmd/compile/internal/gc/ssa.go
+++ b/src/cmd/compile/internal/gc/ssa.go
@@ -455,7 +455,7 @@
return
}
if compiling_runtime != 0 {
- Fatal("%v escapes to heap, not allowed in runtime.", n)
+ Fatalf("%v escapes to heap, not allowed in runtime.", n)
}
// TODO: the old pass hides the details of PHEAP
@@ -1783,7 +1783,7 @@
// Rewrite to an OCALLFUNC: (p.f)(...) becomes (f)(p, ...)
// Take care not to modify the original AST.
if left.Op != ODOTMETH {
- Fatal("OCALLMETH: n.Left not an ODOTMETH: %v", left)
+ Fatalf("OCALLMETH: n.Left not an ODOTMETH: %v", left)
}
newLeft := *left.Right
@@ -2675,7 +2675,7 @@
if f.StaticData != nil {
for _, n := range f.StaticData.([]*Node) {
if !gen_as_init(n, false) {
- Fatal("non-static data marked as static: %v\n\n", n, f)
+ Fatalf("non-static data marked as static: %v\n\n", n, f)
}
}
}
@@ -3468,7 +3468,7 @@
}
case ssa.BlockExit:
case ssa.BlockRet:
- if Hasdefer != 0 {
+ if hasdefer {
s.deferReturn()
}
Prog(obj.ARET)
@@ -3780,7 +3780,7 @@
func (e *ssaExport) Fatalf(msg string, args ...interface{}) {
// If e was marked as unimplemented, anything could happen. Ignore.
if !e.unimplemented {
- Fatal(msg, args...)
+ Fatalf(msg, args...)
}
}
@@ -3788,7 +3788,7 @@
// It will be removed once SSA work is complete.
func (e *ssaExport) Unimplementedf(msg string, args ...interface{}) {
if e.mustImplement {
- Fatal(msg, args...)
+ Fatalf(msg, args...)
}
const alwaysLog = false // enable to calculate top unimplemented features
if !e.unimplemented && (e.log || alwaysLog) {
diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go
index 866d8e1..df5e398 100644
--- a/src/cmd/compile/internal/gc/subr.go
+++ b/src/cmd/compile/internal/gc/subr.go
@@ -181,7 +181,7 @@
}
}
-func Fatal(fmt_ string, args ...interface{}) {
+func Fatalf(fmt_ string, args ...interface{}) {
Flusherrors()
fmt.Printf("%v: internal compiler error: ", Ctxt.Line(int(lineno)))
@@ -339,7 +339,7 @@
s1.Block = s.Block
if s1.Def.Name == nil {
Dump("s1def", s1.Def)
- Fatal("missing Name")
+ Fatalf("missing Name")
}
s1.Def.Name.Pack = pack
s1.Origpkg = opkg
@@ -414,7 +414,7 @@
// the last field, total gives the size of the enclosing struct.
func ispaddedfield(t *Type, total int64) bool {
if t.Etype != TFIELD {
- Fatal("ispaddedfield called non-field %v", t)
+ Fatalf("ispaddedfield called non-field %v", t)
}
if t.Down == nil {
return t.Width+t.Type.Width != total
@@ -426,10 +426,10 @@
if bad != nil {
*bad = nil
}
- if t.Broke != 0 {
+ if t.Broke {
return AMEM
}
- if t.Noalg != 0 {
+ if t.Noalg {
return ANOEQ
}
@@ -530,7 +530,7 @@
return ret
}
- Fatal("algtype1: unexpected type %v", t)
+ Fatalf("algtype1: unexpected type %v", t)
return 0
}
@@ -665,12 +665,7 @@
i++
}
sort.Sort(methcmp(a[:i]))
- for {
- tmp11 := i
- i--
- if tmp11 <= 0 {
- break
- }
+ for i--; i >= 0; i-- {
a[i].Down = f
f = a[i]
}
@@ -709,7 +704,7 @@
n.Type = t
if Isfloat[t.Etype] {
- Fatal("nodconst: bad type %v", t)
+ Fatalf("nodconst: bad type %v", t)
}
}
@@ -775,7 +770,7 @@
}
if m.Name != nil && n.Op != ODCLFIELD {
Dump("treecopy", n)
- Fatal("treecopy Name")
+ Fatalf("treecopy Name")
}
case ONONAME:
@@ -938,7 +933,7 @@
return TFLOAT64
}
- Fatal("cplxsubtype: %v\n", Econv(int(et), 0))
+ Fatalf("cplxsubtype: %v\n", Econv(int(et), 0))
return 0
}
@@ -1010,7 +1005,7 @@
t2 = t2.Type
for ; t1 != nil && t2 != nil; t1, t2 = t1.Down, t2.Down {
if t1.Etype != TFIELD || t2.Etype != TFIELD {
- Fatal("struct/interface missing field: %v %v", t1, t2)
+ Fatalf("struct/interface missing field: %v %v", t1, t2)
}
if t1.Sym != t2.Sym || t1.Embedded != t2.Embedded || !eqtype1(t1.Type, t2.Type, &l) || !eqnote(t1.Note, t2.Note) {
return false
@@ -1028,7 +1023,7 @@
t2 = t2.Type
for ; t1 != nil && t2 != nil; t1, t2 = t1.Down, t2.Down {
if t1.Etype != TSTRUCT || t2.Etype != TSTRUCT {
- Fatal("func missing struct: %v %v", t1, t2)
+ Fatalf("func missing struct: %v %v", t1, t2)
}
// Loop over fields in structs, ignoring argument names.
@@ -1036,7 +1031,7 @@
tb := t2.Type
for ; ta != nil && tb != nil; ta, tb = ta.Down, tb.Down {
if ta.Etype != TFIELD || tb.Etype != TFIELD {
- Fatal("func struct missing field: %v %v", ta, tb)
+ Fatalf("func struct missing field: %v %v", ta, tb)
}
if ta.Isddd != tb.Isddd || !eqtype1(ta.Type, tb.Type, &l) {
return false
@@ -1138,7 +1133,7 @@
}
// we'll have complained about this method anyway, suppress spurious messages.
- if have != nil && have.Sym == missing.Sym && (have.Type.Broke != 0 || missing.Type.Broke != 0) {
+ if have != nil && have.Sym == missing.Sym && (have.Type.Broke || missing.Type.Broke) {
return OCONVIFACE
}
@@ -1322,7 +1317,7 @@
// Convert node n for assignment to type t.
func assignconvfn(n *Node, t *Type, context func() string) *Node {
- if n == nil || n.Type == nil || n.Type.Broke != 0 {
+ if n == nil || n.Type == nil || n.Type.Broke {
return n
}
@@ -1378,7 +1373,7 @@
}
substAny(&n.Type, &types)
if len(types) > 0 {
- Fatal("substArgTypes: too many argument types")
+ Fatalf("substArgTypes: too many argument types")
}
}
@@ -1390,9 +1385,9 @@
if t == nil {
return
}
- if t.Etype == TANY && t.Copyany != 0 {
+ if t.Etype == TANY && t.Copyany {
if len(*types) == 0 {
- Fatal("substArgTypes: not enough argument types")
+ Fatalf("substArgTypes: not enough argument types")
}
*tp = (*types)[0]
*types = (*types)[1:]
@@ -1491,7 +1486,7 @@
case TANY:
nt = shallow(t)
- nt.Copyany = 1
+ nt.Copyany = true
case TPTR32, TPTR64, TCHAN, TARRAY:
nt = shallow(t)
@@ -1526,7 +1521,7 @@
func syslook(name string, copy int) *Node {
s := Pkglookup(name, Runtimepkg)
if s == nil || s.Def == nil {
- Fatal("syslook: can't find runtime.%s", name)
+ Fatalf("syslook: can't find runtime.%s", name)
}
if copy == 0 {
@@ -1600,7 +1595,7 @@
// The returned struct must not be modified.
func Ptrto(t *Type) *Type {
if Tptr == 0 {
- Fatal("ptrto: no tptr")
+ Fatalf("ptrto: no tptr")
}
// Reduce allocations by pre-creating common cases.
if !initPtrtoDone {
@@ -1760,14 +1755,14 @@
}
if t.Etype != TFIELD {
- Fatal("structfirst: not field %v", t)
+ Fatalf("structfirst: not field %v", t)
}
s.T = t
return t
bad:
- Fatal("structfirst: not struct %v", n)
+ Fatalf("structfirst: not struct %v", n)
return nil
}
@@ -1780,7 +1775,7 @@
}
if t.Etype != TFIELD {
- Fatal("structnext: not struct %v", n)
+ Fatalf("structnext: not struct %v", n)
return nil
}
@@ -1814,7 +1809,7 @@
return fp
bad:
- Fatal("funcfirst: not func %v", t)
+ Fatalf("funcfirst: not func %v", t)
return nil
}
@@ -1830,21 +1825,21 @@
func getthis(t *Type) **Type {
if t.Etype != TFUNC {
- Fatal("getthis: not a func %v", t)
+ Fatalf("getthis: not a func %v", t)
}
return &t.Type
}
func Getoutarg(t *Type) **Type {
if t.Etype != TFUNC {
- Fatal("getoutarg: not a func %v", t)
+ Fatalf("getoutarg: not a func %v", t)
}
return &t.Type.Down
}
func getinarg(t *Type) **Type {
if t.Etype != TFUNC {
- Fatal("getinarg: not a func %v", t)
+ Fatalf("getinarg: not a func %v", t)
}
return &t.Type.Down.Down
}
@@ -1878,7 +1873,7 @@
case OGE:
return OLT
}
- Fatal("brcom: no com for %v\n", Oconv(a, 0))
+ Fatalf("brcom: no com for %v\n", Oconv(a, 0))
return a
}
@@ -1899,7 +1894,7 @@
case OGE:
return OLE
}
- Fatal("brrev: no rev for %v\n", Oconv(a, 0))
+ Fatalf("brrev: no rev for %v\n", Oconv(a, 0))
return a
}
@@ -1961,7 +1956,7 @@
// make a copy; must not be used as an lvalue
if islvalue(n) {
- Fatal("missing lvalue case in safeexpr: %v", n)
+ Fatalf("missing lvalue case in safeexpr: %v", n)
}
return cheapexpr(n, init)
}
@@ -2005,11 +2000,11 @@
dowidth(t)
w := t.Argwid
if w >= Thearch.MAXWIDTH {
- Fatal("bad argwid %v", t)
+ Fatalf("bad argwid %v", t)
}
w += int64(extra)
if w >= Thearch.MAXWIDTH {
- Fatal("bad argwid %d + %v", extra, t)
+ Fatalf("bad argwid %d + %v", extra, t)
}
if w > Maxarg {
Maxarg = w
@@ -2499,7 +2494,7 @@
typechecklist(fn.Nbody, Etop)
inlcalls(fn)
- escAnalyze(list1(fn), false)
+ escAnalyze([]*Node{fn}, false)
Curfn = nil
funccompile(fn)
@@ -2526,7 +2521,7 @@
a := algtype1(t, nil)
switch a {
case AMEM:
- Fatal("hashfor with AMEM type")
+ Fatalf("hashfor with AMEM type")
case AINTER:
sym = Pkglookup("interhash", Runtimepkg)
@@ -2601,11 +2596,11 @@
// so t must be either an array or a struct.
switch t.Etype {
default:
- Fatal("genhash %v", t)
+ Fatalf("genhash %v", t)
case TARRAY:
if Isslice(t) {
- Fatal("genhash %v", t)
+ Fatalf("genhash %v", t)
}
// An array of pure memory would be handled by the
@@ -2852,11 +2847,11 @@
// so t must be either an array or a struct.
switch t.Etype {
default:
- Fatal("geneq %v", t)
+ Fatalf("geneq %v", t)
case TARRAY:
if Isslice(t) {
- Fatal("geneq %v", t)
+ Fatalf("geneq %v", t)
}
// An array of pure memory would be handled by the
diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go
index f34b1c6..a0e0c41 100644
--- a/src/cmd/compile/internal/gc/swt.go
+++ b/src/cmd/compile/internal/gc/swt.go
@@ -153,9 +153,9 @@
// reset to original type
ll.N = n.Left.Right
case ll.N.Type.Etype != TINTER && t.Etype == TINTER && !implements(ll.N.Type, t, &missing, &have, &ptr):
- if have != nil && missing.Broke == 0 && have.Broke == 0 {
+ if have != nil && !missing.Broke && !have.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, obj.FmtLong), ll.N.Type, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort), missing.Sym, Tconv(missing.Type, obj.FmtShort))
- } else if missing.Broke == 0 {
+ } else if !missing.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, obj.FmtLong), ll.N.Type, missing.Sym)
}
}
@@ -348,7 +348,7 @@
n := l.N
setlineno(n)
if n.Op != OXCASE {
- Fatal("casebody %v", Oconv(int(n.Op), 0))
+ Fatalf("casebody %v", Oconv(int(n.Op), 0))
}
n.Op = OCASE
needvar := count(n.List) != 1 || n.List.N.Op == OLITERAL
@@ -679,7 +679,7 @@
for _, c := range cc {
n := c.node
if c.typ != caseKindTypeConst {
- Fatal("typeSwitch walkCases")
+ Fatalf("typeSwitch walkCases")
}
a := Nod(OIF, nil, nil)
a.Left = Nod(OEQ, s.hashname, Nodintconst(int64(c.hash)))
diff --git a/src/cmd/compile/internal/gc/syntax.go b/src/cmd/compile/internal/gc/syntax.go
index 7f03a4e..5081ea0 100644
--- a/src/cmd/compile/internal/gc/syntax.go
+++ b/src/cmd/compile/internal/gc/syntax.go
@@ -81,7 +81,7 @@
if n.hasVal == -1 {
Debug['h'] = 1
Dump("have Opt", n)
- Fatal("have Opt")
+ Fatalf("have Opt")
}
n.hasVal = +1
n.E = v.U
@@ -104,7 +104,7 @@
if n.hasVal == +1 {
Debug['h'] = 1
Dump("have Val", n)
- Fatal("have Val")
+ Fatalf("have Val")
}
n.hasVal = -1
n.E = x
diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go
index befe3b2..314c3a9 100644
--- a/src/cmd/compile/internal/gc/typecheck.go
+++ b/src/cmd/compile/internal/gc/typecheck.go
@@ -89,37 +89,30 @@
return fmt.Sprintf("etype=%d", et)
}
-/*
- * sprint_depchain prints a dependency chain
- * of nodes into fmt.
- * It is used by typecheck in the case of OLITERAL nodes
- * to print constant definition loops.
- */
-func sprint_depchain(fmt_ *string, stack *NodeList, cur *Node, first *Node) {
- for l := stack; l != nil; l = l.Next {
- if l.N.Op == cur.Op {
- if l.N != first {
- sprint_depchain(fmt_, l.Next, l.N, first)
+// sprint_depchain prints a dependency chain of nodes into fmt.
+// It is used by typecheck in the case of OLITERAL nodes
+// to print constant definition loops.
+func sprint_depchain(fmt_ *string, stack []*Node, cur *Node, first *Node) {
+ for i := len(stack) - 1; i >= 0; i-- {
+ if n := stack[i]; n.Op == cur.Op {
+ if n != first {
+ sprint_depchain(fmt_, stack[:i], n, first)
}
- *fmt_ += fmt.Sprintf("\n\t%v: %v uses %v", l.N.Line(), l.N, cur)
+ *fmt_ += fmt.Sprintf("\n\t%v: %v uses %v", n.Line(), n, cur)
return
}
}
}
-/*
- * type check node *np.
- * replaces *np with a new pointer in some cases.
- * returns the final value of *np as a convenience.
- */
+var typecheck_tcstack []*Node
-var typecheck_tcstack *NodeList
-var typecheck_tcfree *NodeList
-
+// typecheck type checks node *np.
+// It replaces *np with a new pointer in some cases.
+// It returns the final value of *np as a convenience.
func typecheck(np **Node, top int) *Node {
// cannot type check until all the source has been parsed
- if typecheckok == 0 {
- Fatal("early typecheck")
+ if !typecheckok {
+ Fatalf("early typecheck")
}
n := *np
@@ -168,16 +161,15 @@
Yyerror("%v is not a type", n)
break
}
-
- fmt_ = ""
sprint_depchain(&fmt_, typecheck_tcstack, n, n)
yyerrorl(int(n.Lineno), "constant definition loop%s", fmt_)
}
if nsavederrors+nerrors == 0 {
fmt_ = ""
- for l := typecheck_tcstack; l != nil; l = l.Next {
- fmt_ += fmt.Sprintf("\n\t%v %v", l.N.Line(), l.N)
+ for i := len(typecheck_tcstack) - 1; i >= 0; i-- {
+ x := typecheck_tcstack[i]
+ fmt_ += fmt.Sprintf("\n\t%v %v", x.Line(), x)
}
Yyerror("typechecking loop involving %v%s", n, fmt_)
}
@@ -188,27 +180,15 @@
n.Typecheck = 2
- var l *NodeList
- if typecheck_tcfree != nil {
- l = typecheck_tcfree
- typecheck_tcfree = l.Next
- } else {
- l = new(NodeList)
- }
- l.Next = typecheck_tcstack
- l.N = n
- typecheck_tcstack = l
-
+ typecheck_tcstack = append(typecheck_tcstack, n)
typecheck1(&n, top)
*np = n
+
n.Typecheck = 1
- if typecheck_tcstack != l {
- Fatal("typecheck stack out of sync")
- }
- typecheck_tcstack = l.Next
- l.Next = typecheck_tcfree
- typecheck_tcfree = l
+ last := len(typecheck_tcstack) - 1
+ typecheck_tcstack[last] = nil
+ typecheck_tcstack = typecheck_tcstack[:last]
lineno = int32(lno)
return n
@@ -293,7 +273,7 @@
default:
Dump("typecheck", n)
- Fatal("typecheck %v", Oconv(int(n.Op), 0))
+ Fatalf("typecheck %v", Oconv(int(n.Op), 0))
/*
* names
@@ -368,7 +348,7 @@
} else if l.Op == ODDD {
t.Bound = -100 // to be filled in
if top&Ecomplit == 0 && n.Diag == 0 {
- t.Broke = 1
+ t.Broke = true
n.Diag = 1
Yyerror("use of [...] array outside of array literal")
}
@@ -450,7 +430,7 @@
ok |= Etype
n.Op = OTYPE
n.Type = tostruct(n.List)
- if n.Type == nil || n.Type.Broke != 0 {
+ if n.Type == nil || n.Type.Broke {
n.Type = nil
return
}
@@ -820,7 +800,7 @@
}
if l.Orig != l && l.Op == ONAME {
- Fatal("found non-orig name node %v", l)
+ Fatalf("found non-orig name node %v", l)
}
l.Addrtaken = true
if l.Name != nil && l.Name.Param != nil && l.Name.Param.Closure != nil {
@@ -1306,7 +1286,7 @@
l = n.Left
if l.Op == OTYPE {
if n.Isddd || l.Type.Bound == -100 {
- if l.Type.Broke == 0 {
+ if !l.Type.Broke {
Yyerror("invalid use of ... in type conversion to %v", l.Type)
}
n.Diag = 1
@@ -1354,7 +1334,7 @@
tp := getthisx(t).Type.Type
if l.Left == nil || !Eqtype(l.Left.Type, tp) {
- Fatal("method receiver")
+ Fatalf("method receiver")
}
default:
@@ -1641,7 +1621,7 @@
// Unpack multiple-return result before type-checking.
var funarg *Type
- if Istype(t, TSTRUCT) && t.Funarg != 0 {
+ if Istype(t, TSTRUCT) && t.Funarg {
funarg = t
t = t.Type.Type
}
@@ -1773,7 +1753,7 @@
var why string
n.Op = uint8(convertop(t, n.Type, &why))
if (n.Op) == 0 {
- if n.Diag == 0 && n.Type.Broke == 0 {
+ if n.Diag == 0 && !n.Type.Broke {
Yyerror("cannot convert %v to type %v%s", Nconv(n.Left, obj.FmtLong), n.Type, why)
n.Diag = 1
}
@@ -2008,7 +1988,7 @@
return
}
if t.Etype != TINTER {
- Fatal("OITAB of %v", t)
+ Fatalf("OITAB of %v", t)
}
n.Type = Ptrto(Types[TUINTPTR])
break OpSwitch
@@ -2022,7 +2002,7 @@
return
}
if !Isslice(t) && t.Etype != TSTRING {
- Fatal("OSPTR of %v", t)
+ Fatalf("OSPTR of %v", t)
}
if t.Etype == TSTRING {
n.Type = Ptrto(Types[TUINT8])
@@ -2137,7 +2117,7 @@
return
}
- if Curfn.Type.Outnamed != 0 && n.List == nil {
+ if Curfn.Type.Outnamed && n.List == nil {
break OpSwitch
}
typecheckaste(ORETURN, nil, false, getoutargx(Curfn.Type), n.List, func() string { return "return argument" })
@@ -2193,7 +2173,7 @@
}
t := n.Type
- if t != nil && t.Funarg == 0 && n.Op != OTYPE {
+ if t != nil && !t.Funarg && n.Op != OTYPE {
switch t.Etype {
case TFUNC, // might have TANY; wait until its called
TANY,
@@ -2327,7 +2307,7 @@
// type is broken or missing, most likely a method call on a broken type
// we will warn about the broken type elsewhere. no need to emit a potentially confusing error
- if n.Left.Type == nil || n.Left.Type.Broke != 0 {
+ if n.Left.Type == nil || n.Left.Type.Broke {
return
}
@@ -2527,7 +2507,7 @@
Yyerror("%v is both field and method", n.Right.Sym)
}
if f1.Width == BADWIDTH {
- Fatal("lookdot badwidth %v %p", f1, f1)
+ Fatalf("lookdot badwidth %v %p", f1, f1)
}
n.Xoffset = f1.Width
n.Type = f1.Type
@@ -2578,7 +2558,7 @@
tt = tt.Type
}
} else {
- Fatal("method mismatch: %v for %v", rcvr, tt)
+ Fatalf("method mismatch: %v for %v", rcvr, tt)
}
}
@@ -2647,7 +2627,7 @@
lno := int(lineno)
- if tstruct.Broke != 0 {
+ if tstruct.Broke {
goto out
}
@@ -2655,7 +2635,7 @@
if nl != nil && nl.Next == nil {
n = nl.N
if n.Type != nil {
- if n.Type.Etype == TSTRUCT && n.Type.Funarg != 0 {
+ if n.Type.Etype == TSTRUCT && n.Type.Funarg {
if !hasddd(tstruct) {
n1 := downcount(tstruct)
n2 := downcount(n.Type)
@@ -2820,7 +2800,7 @@
*/
func fielddup(n *Node, hash map[string]bool) {
if n.Op != ONAME {
- Fatal("fielddup: not ONAME")
+ Fatalf("fielddup: not ONAME")
}
name := n.Sym.Name
if hash[name] {
@@ -2893,7 +2873,7 @@
func indexdup(n *Node, hash map[int64]*Node) {
if n.Op != OLITERAL {
- Fatal("indexdup: not OLITERAL")
+ Fatalf("indexdup: not OLITERAL")
}
v := Mpgetfix(n.Val().U.(*Mpint))
@@ -3093,11 +3073,10 @@
setlineno(ll.N)
typecheck(&ll.N, Erv)
if f == nil {
- tmp12 := bad
- bad++
- if tmp12 == 0 {
+ if bad == 0 {
Yyerror("too many values in struct initializer")
}
+ bad++
continue
}
@@ -3130,11 +3109,10 @@
l = ll.N
setlineno(l)
if l.Op != OKEY {
- tmp13 := bad
- bad++
- if tmp13 == 0 {
+ if bad == 0 {
Yyerror("mixture of field:value and value initializers")
}
+ bad++
typecheck(&ll.N, Erv)
continue
}
@@ -3397,7 +3375,7 @@
}
switch r.Op {
case OCALLMETH, OCALLINTER, OCALLFUNC:
- if r.Type.Etype != TSTRUCT || r.Type.Funarg == 0 {
+ if r.Type.Etype != TSTRUCT || !r.Type.Funarg {
break
}
cr = structcount(r.Type)
@@ -3497,7 +3475,7 @@
func stringtoarraylit(np **Node) {
n := *np
if n.Left.Op != OLITERAL || n.Left.Val().Ctype() != CTSTR {
- Fatal("stringtoarraylit %v", n)
+ Fatalf("stringtoarraylit %v", n)
}
s := n.Left.Val().U.(string)
@@ -3578,12 +3556,11 @@
if n.Name != nil {
t.Vargen = n.Name.Vargen
}
- t.Siggen = 0
t.Method = nil
t.Xmethod = nil
t.Nod = nil
- t.Printed = 0
- t.Deferwidth = 0
+ t.Printed = false
+ t.Deferwidth = false
t.Copyto = nil
// Update nodes waiting on this type.
@@ -3709,7 +3686,7 @@
fmt.Printf(" %v", l.N.Sym)
}
fmt.Printf("\n")
- Fatal("typecheckdef loop")
+ Fatalf("typecheckdef loop")
}
n.Walkdef = 2
@@ -3720,7 +3697,7 @@
switch n.Op {
default:
- Fatal("typecheckdef %v", Oconv(int(n.Op), 0))
+ Fatalf("typecheckdef %v", Oconv(int(n.Op), 0))
// not really syms
case OGOTO, OLABEL:
@@ -3803,7 +3780,7 @@
break
}
- Fatal("var without type, init: %v", n.Sym)
+ Fatalf("var without type, init: %v", n.Sym)
}
if n.Name.Defn.Op == ONAME {
@@ -3826,7 +3803,7 @@
if n.Type.Etype == TFORW && nerrors > nerrors0 {
// Something went wrong during type-checking,
// but it was reported. Silence future errors.
- n.Type.Broke = 1
+ n.Type.Broke = true
}
if Curfn != nil {
@@ -3840,10 +3817,10 @@
ret:
if n.Op != OLITERAL && n.Type != nil && isideal(n.Type) {
- Fatal("got %v for %v", n.Type, n)
+ Fatalf("got %v for %v", n.Type, n)
}
if typecheckdefstack.N != n {
- Fatal("typecheckdefstack mismatch")
+ Fatalf("typecheckdefstack mismatch")
}
l = typecheckdefstack
typecheckdefstack = l.Next
diff --git a/src/cmd/compile/internal/gc/unsafe.go b/src/cmd/compile/internal/gc/unsafe.go
index a01765b..44a658f 100644
--- a/src/cmd/compile/internal/gc/unsafe.go
+++ b/src/cmd/compile/internal/gc/unsafe.go
@@ -89,7 +89,7 @@
default:
Dump("unsafenmagic", r)
- Fatal("impossible %v node after dot insertion", Oconv(int(r1.Op), obj.FmtSharp))
+ Fatalf("impossible %v node after dot insertion", Oconv(int(r1.Op), obj.FmtSharp))
goto bad
}
}
diff --git a/src/cmd/compile/internal/gc/util.go b/src/cmd/compile/internal/gc/util.go
index c59af06..8620e0b 100644
--- a/src/cmd/compile/internal/gc/util.go
+++ b/src/cmd/compile/internal/gc/util.go
@@ -78,10 +78,10 @@
if cpuprofile != "" {
f, err := os.Create(cpuprofile)
if err != nil {
- Fatal("%v", err)
+ Fatalf("%v", err)
}
if err := pprof.StartCPUProfile(f); err != nil {
- Fatal("%v", err)
+ Fatalf("%v", err)
}
AtExit(pprof.StopCPUProfile)
}
@@ -91,12 +91,12 @@
}
f, err := os.Create(memprofile)
if err != nil {
- Fatal("%v", err)
+ Fatalf("%v", err)
}
AtExit(func() {
runtime.GC() // profile all outstanding allocations
if err := pprof.WriteHeapProfile(f); err != nil {
- Fatal("%v", err)
+ Fatalf("%v", err)
}
})
}
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index af3e1cc..ae19e6f 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -182,7 +182,7 @@
ORECOVER,
OGETG:
if n.Typecheck == 0 {
- Fatal("missing typecheck: %v", Nconv(n, obj.FmtSign))
+ Fatalf("missing typecheck: %v", Nconv(n, obj.FmtSign))
}
init := n.Ninit
n.Ninit = nil
@@ -196,7 +196,7 @@
// the value received.
case ORECV:
if n.Typecheck == 0 {
- Fatal("missing typecheck: %v", Nconv(n, obj.FmtSign))
+ Fatalf("missing typecheck: %v", Nconv(n, obj.FmtSign))
}
init := n.Ninit
n.Ninit = nil
@@ -231,7 +231,7 @@
walkstmt(&n.Right)
case ODEFER:
- Hasdefer = 1
+ hasdefer = true
switch n.Left.Op {
case OPRINT, OPRINTN:
walkprintfunc(&n.Left, &n.Ninit)
@@ -283,7 +283,7 @@
if n.List == nil {
break
}
- if (Curfn.Type.Outnamed != 0 && count(n.List) > 1) || paramoutheap(Curfn) {
+ if (Curfn.Type.Outnamed && count(n.List) > 1) || paramoutheap(Curfn) {
// assign to the function out parameters,
// so that reorder3 can fix up conflicts
var rl *NodeList
@@ -311,7 +311,7 @@
f := n.List.N
if f.Op != OCALLFUNC && f.Op != OCALLMETH && f.Op != OCALLINTER {
- Fatal("expected return of call, have %v", f)
+ Fatalf("expected return of call, have %v", f)
}
n.List = concat(list1(f), ascompatet(int(n.Op), rl, &f.Type, 0, &n.Ninit))
break
@@ -346,7 +346,7 @@
}
if n.Op == ONAME {
- Fatal("walkstmt ended up with name: %v", Nconv(n, obj.FmtSign))
+ Fatalf("walkstmt ended up with name: %v", Nconv(n, obj.FmtSign))
}
*np = n
@@ -404,7 +404,7 @@
// not okay to use n->ninit when walking n,
// because we might replace n with some other node
// and would lose the init list.
- Fatal("walkexpr init == &n->ninit")
+ Fatalf("walkexpr init == &n->ninit")
}
if n.Ninit != nil {
@@ -427,13 +427,13 @@
}
if n.Typecheck != 1 {
- Fatal("missed typecheck: %v\n", Nconv(n, obj.FmtSign))
+ Fatalf("missed typecheck: %v\n", Nconv(n, obj.FmtSign))
}
switch n.Op {
default:
Dump("walk", n)
- Fatal("walkexpr: switch 1 unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
+ Fatalf("walkexpr: switch 1 unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
case OTYPE,
ONONAME,
@@ -872,11 +872,6 @@
typecheck(&n, Etop)
walkexpr(&n, init)
- // mapaccess needs a zero value to be at least this big.
- if zerosize < t.Type.Width {
- zerosize = t.Type.Width
- }
-
// TODO: ptr is always non-nil, so disable nil check for this OIND op.
goto ret
@@ -973,7 +968,7 @@
case ODOTTYPE, ODOTTYPE2:
if !isdirectiface(n.Type) || Isfat(n.Type) {
- Fatal("walkexpr ODOTTYPE") // should see inside OAS only
+ Fatalf("walkexpr ODOTTYPE") // should see inside OAS only
}
walkexpr(&n.Left, init)
goto ret
@@ -1285,14 +1280,10 @@
n.Type = t.Type
n.Typecheck = 1
- // mapaccess needs a zero value to be at least this big.
- if zerosize < t.Type.Width {
- zerosize = t.Type.Width
- }
goto ret
case ORECV:
- Fatal("walkexpr ORECV") // should see inside OAS only
+ Fatalf("walkexpr ORECV") // should see inside OAS only
case OSLICE, OSLICEARR, OSLICESTR:
walkexpr(&n.Left, init)
@@ -1336,7 +1327,7 @@
case ONEW:
if n.Esc == EscNone {
if n.Type.Type.Width >= 1<<16 {
- Fatal("large ONEW with EscNone: %v", n)
+ Fatalf("large ONEW with EscNone: %v", n)
}
r := temp(n.Type.Type)
r = Nod(OAS, r, nil) // zero temp
@@ -1406,7 +1397,7 @@
typecheck(&r, Erv)
if n.Type.Etype != TBOOL {
- Fatal("cmp %v", n.Type)
+ Fatalf("cmp %v", n.Type)
}
r.Type = n.Type
n = r
@@ -1418,7 +1409,7 @@
case OAPPEND:
// order should make sure we only see OAS(node, OAPPEND), which we handle above.
- Fatal("append outside assignment")
+ Fatalf("append outside assignment")
case OCOPY:
n = copyany(n, init, flag_race)
@@ -1477,7 +1468,7 @@
t := n.Type
if n.Esc == EscNone {
if !isSmallMakeSlice(n) {
- Fatal("non-small OMAKESLICE with EscNone: %v", n)
+ Fatalf("non-small OMAKESLICE with EscNone: %v", n)
}
// var arr [r]T
// n = arr[:l]
@@ -1585,7 +1576,7 @@
// ifaceeq(i1 any-1, i2 any-2) (ret bool);
case OCMPIFACE:
if !Eqtype(n.Left.Type, n.Right.Type) {
- Fatal("ifaceeq %v %v %v", Oconv(int(n.Op), 0), n.Left.Type, n.Right.Type)
+ Fatalf("ifaceeq %v %v %v", Oconv(int(n.Op), 0), n.Left.Type, n.Right.Type)
}
var fn *Node
if isnilinter(n.Left.Type) {
@@ -1637,7 +1628,7 @@
goto ret
}
- Fatal("missing switch %v", Oconv(int(n.Op), 0))
+ Fatalf("missing switch %v", Oconv(int(n.Op), 0))
// Expressions that are constant at run time but not
// considered const by the language spec are not turned into
@@ -1800,7 +1791,7 @@
}
if ucount != 0 {
- Fatal("ascompatet: too many function calls evaluating parameters")
+ Fatalf("ascompatet: too many function calls evaluating parameters")
}
return concat(nn, mm)
}
@@ -1831,7 +1822,7 @@
n.Esc = esc
typecheck(&n, Erv)
if n.Type == nil {
- Fatal("mkdotargslice: typecheck failed")
+ Fatalf("mkdotargslice: typecheck failed")
}
walkexpr(&n, init)
}
@@ -1909,7 +1900,7 @@
var l2 string
var ll *Type
var l1 string
- if r != nil && lr.Next == nil && r.Type.Etype == TSTRUCT && r.Type.Funarg != 0 {
+ if r != nil && lr.Next == nil && r.Type.Etype == TSTRUCT && r.Type.Funarg {
// optimization - can do block copy
if eqtypenoname(r.Type, *nl) {
a := nodarg(*nl, fp)
@@ -2249,7 +2240,7 @@
func convas(n *Node, init **NodeList) *Node {
if n.Op != OAS {
- Fatal("convas: not OAS %v", Oconv(int(n.Op), 0))
+ Fatalf("convas: not OAS %v", Oconv(int(n.Op), 0))
}
n.Typecheck = 1
@@ -2400,7 +2391,7 @@
switch l.Op {
default:
- Fatal("reorder3 unexpected lvalue %v", Oconv(int(l.Op), obj.FmtSharp))
+ Fatalf("reorder3 unexpected lvalue %v", Oconv(int(l.Op), obj.FmtSharp))
case ONAME:
break
@@ -2450,7 +2441,7 @@
func outervalue(n *Node) *Node {
for {
if n.Op == OXDOT {
- Fatal("OXDOT in walk")
+ Fatalf("OXDOT in walk")
}
if n.Op == ODOT || n.Op == OPAREN || n.Op == OCONVNOP {
n = n.Left
@@ -2748,7 +2739,7 @@
func vmkcall(fn *Node, t *Type, init **NodeList, va []*Node) *Node {
if fn.Type == nil || fn.Type.Etype != TFUNC {
- Fatal("mkcall %v %v", fn, fn.Type)
+ Fatalf("mkcall %v %v", fn, fn.Type)
}
var args *NodeList
@@ -2789,12 +2780,12 @@
func chanfn(name string, n int, t *Type) *Node {
if t.Etype != TCHAN {
- Fatal("chanfn %v", t)
+ Fatalf("chanfn %v", t)
}
fn := syslook(name, 1)
switch n {
default:
- Fatal("chanfn %d", n)
+ Fatalf("chanfn %d", n)
case 1:
substArgTypes(fn, t.Type)
case 2:
@@ -2805,7 +2796,7 @@
func mapfn(name string, t *Type) *Node {
if t.Etype != TMAP {
- Fatal("mapfn %v", t)
+ Fatalf("mapfn %v", t)
}
fn := syslook(name, 1)
substArgTypes(fn, t.Down, t.Type, t.Down, t.Type)
@@ -2814,7 +2805,7 @@
func mapfndel(name string, t *Type) *Node {
if t.Etype != TMAP {
- Fatal("mapfn %v", t)
+ Fatalf("mapfn %v", t)
}
fn := syslook(name, 1)
substArgTypes(fn, t.Down, t.Type, t.Down)
@@ -3165,7 +3156,7 @@
a := algtype1(t, nil)
if a != AMEM && a != -1 {
- Fatal("eqfor %v", t)
+ Fatalf("eqfor %v", t)
}
if a == AMEM {
@@ -3277,7 +3268,7 @@
}
if !islvalue(cmpl) || !islvalue(cmpr) {
- Fatal("arguments of comparison must be lvalues - %v %v", cmpl, cmpr)
+ Fatalf("arguments of comparison must be lvalues - %v %v", cmpl, cmpr)
}
l = temp(Ptrto(t))
@@ -3868,7 +3859,7 @@
switch n.Op {
default:
- Fatal("usefield %v", Oconv(int(n.Op), 0))
+ Fatalf("usefield %v", Oconv(int(n.Op), 0))
case ODOT, ODOTPTR:
break
@@ -3880,7 +3871,7 @@
}
field := dotField[typeSym{t.Orig, n.Right.Sym}]
if field == nil {
- Fatal("usefield %v %v without paramfld", n.Left.Type, n.Right.Sym)
+ Fatalf("usefield %v %v without paramfld", n.Left.Type, n.Right.Sym)
}
if field.Note == nil || !strings.Contains(*field.Note, "go:\"track\"") {
return
diff --git a/src/cmd/compile/internal/gc/y.go b/src/cmd/compile/internal/gc/y.go
index 2b61c07..fafbdf1 100644
--- a/src/cmd/compile/internal/gc/y.go
+++ b/src/cmd/compile/internal/gc/y.go
@@ -1057,6 +1057,7 @@
var yylval yySymType
var yyVAL yySymType
var yyDollar []yySymType
+ _ = yyDollar // silence set and not used
yyS := make([]yySymType, yyMaxDepth)
Nerrs := 0 /* number of errors */
@@ -1313,7 +1314,7 @@
// no package statement. This allows us to test more
// than one invalid import statement in a single file.
if nerrors == 0 {
- Fatal("phase error in import")
+ Fatalf("phase error in import")
}
}
case 15:
@@ -1353,7 +1354,7 @@
} else if importpkg.Name != yyDollar[2].sym.Name {
Yyerror("conflicting names %s and %s for package %q", importpkg.Name, yyDollar[2].sym.Name, importpkg.Path)
}
- importpkg.Direct = 1
+ importpkg.Direct = true
importpkg.Safe = curio.importsafe
if safemode != 0 && !curio.importsafe {
@@ -3240,7 +3241,7 @@
yyDollar[2].node.Func.Inl = yyDollar[3].list
funcbody(yyDollar[2].node)
- importlist = list(importlist, yyDollar[2].node)
+ importlist = append(importlist, yyDollar[2].node)
if Debug['E'] > 0 {
fmt.Printf("import [%q] func %v \n", importpkg.Path, yyDollar[2].node)