Commit d7012ca2 authored by Dave Cheney's avatar Dave Cheney

cmd/compile/internal/gc: unexport more helper functions

After the removal of the old backend many types are no longer referenced
outside internal/gc. Make these functions private so that tools like
honnef.co/go/unused can spot when they become dead code. In doing so
this CL identified several previously public helpers which are no longer
used, so removes them.

This should be the last of the public functions.

Change-Id: I7e9c4e72f86f391b428b9dddb6f0d516529706c3
Reviewed-on: https://go-review.googlesource.com/29134
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 896ac677
......@@ -198,10 +198,10 @@ func genhash(sym *Sym, t *Type) {
tfn := Nod(OTFUNC, nil, nil)
fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
n := Nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t)))
tfn.List.Append(n)
np := n.Left
n = Nod(ODCLFIELD, newname(Lookup("h")), typenod(Types[TUINTPTR]))
n = Nod(ODCLFIELD, newname(lookup("h")), typenod(Types[TUINTPTR]))
tfn.List.Append(n)
nh := n.Left
n = Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])) // return value
......@@ -224,7 +224,7 @@ func genhash(sym *Sym, t *Type) {
hashel := hashfor(t.Elem())
n := Nod(ORANGE, nil, Nod(OIND, np, nil))
ni := newname(Lookup("i"))
ni := newname(lookup("i"))
ni.Type = Types[TINT]
n.List.Set1(ni)
n.Colas = true
......@@ -260,7 +260,7 @@ func genhash(sym *Sym, t *Type) {
if !f.Type.IsRegularMemory() {
hashel := hashfor(f.Type)
call := Nod(OCALL, hashel, nil)
nx := NodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
nx := nodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap
call.List.Append(na)
......@@ -276,7 +276,7 @@ func genhash(sym *Sym, t *Type) {
// h = hashel(&p.first, size, h)
hashel := hashmem(f.Type)
call := Nod(OCALL, hashel, nil)
nx := NodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
nx := nodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap
call.List.Append(na)
......@@ -347,7 +347,7 @@ func hashfor(t *Type) *Node {
n := newname(sym)
n.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil)
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(ptrto(t))))
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn = typecheck(tfn, Etype)
......@@ -374,10 +374,10 @@ func geneq(sym *Sym, t *Type) {
tfn := Nod(OTFUNC, nil, nil)
fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
n := Nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t)))
tfn.List.Append(n)
np := n.Left
n = Nod(ODCLFIELD, newname(Lookup("q")), typenod(Ptrto(t)))
n = Nod(ODCLFIELD, newname(lookup("q")), typenod(ptrto(t)))
tfn.List.Append(n)
nq := n.Left
n = Nod(ODCLFIELD, nil, typenod(Types[TBOOL]))
......@@ -401,7 +401,7 @@ func geneq(sym *Sym, t *Type) {
// unrolling.
nrange := Nod(ORANGE, nil, Nod(OIND, np, nil))
ni := newname(Lookup("i"))
ni := newname(lookup("i"))
ni.Type = Types[TINT]
nrange.List.Set1(ni)
nrange.Colas = true
......@@ -418,14 +418,14 @@ func geneq(sym *Sym, t *Type) {
nif := Nod(OIF, nil, nil)
nif.Left = Nod(ONE, nx, ny)
r := Nod(ORETURN, nil, nil)
r.List.Append(Nodbool(false))
r.List.Append(nodbool(false))
nif.Nbody.Append(r)
nrange.Nbody.Append(nif)
fn.Nbody.Append(nrange)
// return true
ret := Nod(ORETURN, nil, nil)
ret.List.Append(Nodbool(true))
ret.List.Append(nodbool(true))
fn.Nbody.Append(ret)
case TSTRUCT:
......@@ -474,7 +474,7 @@ func geneq(sym *Sym, t *Type) {
}
if cond == nil {
cond = Nodbool(true)
cond = nodbool(true)
}
ret := Nod(ORETURN, nil, nil)
......@@ -518,8 +518,8 @@ func geneq(sym *Sym, t *Type) {
// eqfield returns the node
// p.field == q.field
func eqfield(p *Node, q *Node, field *Sym) *Node {
nx := NodSym(OXDOT, p, field)
ny := NodSym(OXDOT, q, field)
nx := nodSym(OXDOT, p, field)
ny := nodSym(OXDOT, q, field)
ne := Nod(OEQ, nx, ny)
return ne
}
......@@ -527,9 +527,9 @@ func eqfield(p *Node, q *Node, field *Sym) *Node {
// eqmem returns the node
// memequal(&p.field, &q.field [, size])
func eqmem(p *Node, q *Node, field *Sym, size int64) *Node {
nx := Nod(OADDR, NodSym(OXDOT, p, field), nil)
nx := Nod(OADDR, nodSym(OXDOT, p, field), nil)
nx.Etype = 1 // does not escape
ny := Nod(OADDR, NodSym(OXDOT, q, field), nil)
ny := Nod(OADDR, nodSym(OXDOT, q, field), nil)
ny.Etype = 1 // does not escape
nx = typecheck(nx, Erv)
ny = typecheck(ny, Erv)
......
......@@ -21,7 +21,7 @@ func offmod(t *Type) {
f.Offset = int64(o)
o += int32(Widthptr)
if int64(o) >= Thearch.MAXWIDTH {
Yyerror("interface too large")
yyerror("interface too large")
o = int32(Widthptr)
}
}
......@@ -75,7 +75,7 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 {
}
o += w
if o >= Thearch.MAXWIDTH {
Yyerror("type %L too large", errtype)
yyerror("type %L too large", errtype)
o = 8 // small but nonzero
}
}
......@@ -208,7 +208,7 @@ func dowidth(t *Type) {
t1 := t.ChanArgs()
dowidth(t1) // just in case
if t1.Elem().Width >= 1<<16 {
Yyerror("channel element type too large (>64kB)")
yyerror("channel element type too large (>64kB)")
}
t.Width = 1
......@@ -219,7 +219,7 @@ func dowidth(t *Type) {
case TFORW: // should have been filled in
if !t.Broke {
Yyerror("invalid recursive type %v", t)
yyerror("invalid recursive type %v", t)
}
w = 1 // anything will do
......@@ -243,7 +243,7 @@ func dowidth(t *Type) {
}
if t.isDDDArray() {
if !t.Broke {
Yyerror("use of [...] array outside of array literal")
yyerror("use of [...] array outside of array literal")
t.Broke = true
}
break
......@@ -253,7 +253,7 @@ func dowidth(t *Type) {
if t.Elem().Width != 0 {
cap := (uint64(Thearch.MAXWIDTH) - 1) / uint64(t.Elem().Width)
if uint64(t.NumElem()) > cap {
Yyerror("type %L larger than address space", t)
yyerror("type %L larger than address space", t)
}
}
w = t.NumElem() * t.Elem().Width
......@@ -295,7 +295,7 @@ func dowidth(t *Type) {
}
if Widthptr == 4 && w != int64(int32(w)) {
Yyerror("type %v too large", t)
yyerror("type %v too large", t)
}
t.Width = w
......
......@@ -225,7 +225,7 @@ func formatErrorf(format string, args ...interface{}) {
Fatalf(format, args...)
}
Yyerror("cannot import %q due to version skew - reinstall package (%s)",
yyerror("cannot import %q due to version skew - reinstall package (%s)",
importpkg.Path, fmt.Sprintf(format, args...))
errorexit()
}
......@@ -287,10 +287,10 @@ func (p *importer) pkg() *Pkg {
pkg.Name = name
numImport[name]++
} else if pkg.Name != name {
Yyerror("conflicting package names %s and %s for path %q", pkg.Name, name, path)
yyerror("conflicting package names %s and %s for path %q", pkg.Name, name, path)
}
if myimportpath != "" && path == myimportpath {
Yyerror("import %q: package depends on %q (import cycle)", importpkg.Path, path)
yyerror("import %q: package depends on %q (import cycle)", importpkg.Path, path)
errorexit()
}
p.pkgList = append(p.pkgList, pkg)
......@@ -405,7 +405,7 @@ func (p *importer) importtype(pt, t *Type) {
// Collect the types and verify identity later.
p.cmpList = append(p.cmpList, struct{ pt, t *Type }{pt, t})
} else if !eqtype(pt.Orig, t) {
Yyerror("inconsistent definition for type %v during import\n\t%L (in %q)\n\t%L (in %q)", pt.Sym, pt, pt.Sym.Importdef.Path, t, importpkg.Path)
yyerror("inconsistent definition for type %v during import\n\t%L (in %q)\n\t%L (in %q)", pt.Sym, pt, pt.Sym.Importdef.Path, t, importpkg.Path)
}
}
......@@ -905,7 +905,7 @@ func (p *importer) node() *Node {
case OXDOT:
// see parser.new_dotname
return NodSym(OXDOT, p.expr(), p.fieldSym())
return nodSym(OXDOT, p.expr(), p.fieldSym())
// case ODOTTYPE, ODOTTYPE2:
// unreachable - mapped to case ODOTTYPE below by exporter
......
......@@ -195,7 +195,7 @@ func closurename(n *Node) *Sym {
default:
Fatalf("closurename called for %S", n)
}
n.Sym = Lookupf("%s.%s%d", outer, prefix, gen)
n.Sym = lookupf("%s.%s%d", outer, prefix, gen)
return n.Sym
}
......@@ -342,8 +342,8 @@ func transformclosure(xfunc *Node) {
// we introduce function param &v *T
// and v remains PAUTOHEAP with &v heapaddr
// (accesses will implicitly deref &v).
addr := newname(Lookupf("&%s", v.Sym.Name))
addr.Type = Ptrto(v.Type)
addr := newname(lookupf("&%s", v.Sym.Name))
addr.Type = ptrto(v.Type)
addr.Class = PPARAM
v.Name.Heapaddr = addr
fld.Nname = addr
......@@ -382,7 +382,7 @@ func transformclosure(xfunc *Node) {
cv.Type = v.Type
if !v.Name.Byval {
cv.Type = Ptrto(v.Type)
cv.Type = ptrto(v.Type)
}
offset = Rnd(offset, int64(cv.Type.Align))
cv.Xoffset = offset
......@@ -397,7 +397,7 @@ func transformclosure(xfunc *Node) {
} else {
// Declare variable holding addresses taken from closure
// and initialize in entry prologue.
addr := newname(Lookupf("&%s", v.Sym.Name))
addr := newname(lookupf("&%s", v.Sym.Name))
addr.Name.Param.Ntype = Nod(OIND, typenod(v.Type), nil)
addr.Class = PAUTO
addr.Used = true
......@@ -476,7 +476,7 @@ func walkclosure(func_ *Node, init *Nodes) *Node {
typ := Nod(OTSTRUCT, nil, nil)
typ.List.Set1(Nod(ODCLFIELD, newname(Lookup(".F")), typenod(Types[TUINTPTR])))
typ.List.Set1(Nod(ODCLFIELD, newname(lookup(".F")), typenod(Types[TUINTPTR])))
for _, v := range func_.Func.Cvars.Slice() {
if v.Op == OXXX {
continue
......@@ -580,7 +580,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
xfunc := Nod(ODCLFUNC, nil, nil)
Curfn = xfunc
for i, t := range t0.Params().Fields().Slice() {
n := newname(LookupN("a", i))
n := newname(lookupN("a", i))
n.Class = PPARAM
xfunc.Func.Dcl = append(xfunc.Func.Dcl, n)
callargs = append(callargs, n)
......@@ -597,7 +597,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
l = nil
var retargs []*Node
for i, t := range t0.Results().Fields().Slice() {
n := newname(LookupN("r", i))
n := newname(lookupN("r", i))
n.Class = PPARAMOUT
xfunc.Func.Dcl = append(xfunc.Func.Dcl, n)
retargs = append(retargs, n)
......@@ -623,7 +623,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
cv.Xoffset = int64(cv.Type.Align)
}
ptr := Nod(ONAME, nil, nil)
ptr.Sym = Lookup("rcvr")
ptr.Sym = lookup("rcvr")
ptr.Class = PAUTO
ptr.Addable = true
ptr.Ullman = 1
......@@ -636,11 +636,11 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
ptr.Name.Param.Ntype = typenod(rcvrtype)
body = append(body, Nod(OAS, ptr, cv))
} else {
ptr.Name.Param.Ntype = typenod(Ptrto(rcvrtype))
ptr.Name.Param.Ntype = typenod(ptrto(rcvrtype))
body = append(body, Nod(OAS, ptr, Nod(OADDR, cv, nil)))
}
call := Nod(OCALL, NodSym(OXDOT, ptr, meth), nil)
call := Nod(OCALL, nodSym(OXDOT, ptr, meth), nil)
call.List.Set(callargs)
call.Isddd = ddd
if t0.Results().NumFields() == 0 {
......@@ -681,8 +681,8 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
}
typ := Nod(OTSTRUCT, nil, nil)
typ.List.Set1(Nod(ODCLFIELD, newname(Lookup("F")), typenod(Types[TUINTPTR])))
typ.List.Append(Nod(ODCLFIELD, newname(Lookup("R")), typenod(n.Left.Type)))
typ.List.Set1(Nod(ODCLFIELD, newname(lookup("F")), typenod(Types[TUINTPTR])))
typ.List.Append(Nod(ODCLFIELD, newname(lookup("R")), typenod(n.Left.Type)))
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
clos.Esc = n.Esc
......
......@@ -190,13 +190,6 @@ func truncfltlit(oldv *Mpflt, t *Type) *Mpflt {
return fv
}
// NegOne returns a Node of type t with value -1.
func NegOne(t *Type) *Node {
n := nodintconst(-1)
n = convlit(n, t)
return n
}
// canReuseNode indicates whether it is known to be safe
// to reuse a Node.
type canReuseNode bool
......@@ -265,7 +258,7 @@ func convlit1(n *Node, t *Type, explicit bool, reuse canReuseNode) *Node {
n.SetVal(toint(n.Val()))
}
if t != nil && !t.IsInteger() {
Yyerror("invalid operation: %v (shift of type %v)", n, t)
yyerror("invalid operation: %v (shift of type %v)", n, t)
t = nil
}
......@@ -412,7 +405,7 @@ func convlit1(n *Node, t *Type, explicit bool, reuse canReuseNode) *Node {
bad:
if n.Diag == 0 {
if !t.Broke {
Yyerror("cannot convert %v to type %v", n, t)
yyerror("cannot convert %v to type %v", n, t)
}
n.Diag = 1
}
......@@ -475,7 +468,7 @@ func toflt(v Val) Val {
f := newMpflt()
f.Set(&u.Real)
if u.Imag.CmpFloat64(0) != 0 {
Yyerror("constant %v%vi truncated to real", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
yyerror("constant %v%vi truncated to real", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
}
v.U = f
}
......@@ -500,17 +493,17 @@ func toint(v Val) Val {
if u.Val.IsInt() {
msg = "constant %v overflows integer"
}
Yyerror(msg, fconv(u, FmtSharp))
yyerror(msg, fconv(u, FmtSharp))
}
v.U = i
case *Mpcplx:
i := new(Mpint)
if i.SetFloat(&u.Real) < 0 {
Yyerror("constant %v%vi truncated to integer", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
yyerror("constant %v%vi truncated to integer", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
}
if u.Imag.CmpFloat64(0) != 0 {
Yyerror("constant %v%vi truncated to real", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
yyerror("constant %v%vi truncated to real", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
}
v.U = i
}
......@@ -556,7 +549,7 @@ func overflow(v Val, t *Type) {
}
if doesoverflow(v, t) {
Yyerror("constant %v overflows %v", v, t)
yyerror("constant %v overflows %v", v, t)
}
}
......@@ -744,7 +737,7 @@ func evconst(n *Node) {
switch uint32(n.Op)<<16 | uint32(v.Ctype()) {
default:
if n.Diag == 0 {
Yyerror("illegal constant expression %v %v", n.Op, nl.Type)
yyerror("illegal constant expression %v %v", n.Op, nl.Type)
n.Diag = 1
}
return
......@@ -939,7 +932,7 @@ func evconst(n *Node) {
case ODIV_ | CTINT_,
ODIV_ | CTRUNE_:
if rv.U.(*Mpint).CmpInt64(0) == 0 {
Yyerror("division by zero")
yyerror("division by zero")
v.U.(*Mpint).SetOverflow()
break
}
......@@ -949,7 +942,7 @@ func evconst(n *Node) {
case OMOD_ | CTINT_,
OMOD_ | CTRUNE_:
if rv.U.(*Mpint).CmpInt64(0) == 0 {
Yyerror("division by zero")
yyerror("division by zero")
v.U.(*Mpint).SetOverflow()
break
}
......@@ -991,7 +984,7 @@ func evconst(n *Node) {
case ODIV_ | CTFLT_:
if rv.U.(*Mpflt).CmpFloat64(0) == 0 {
Yyerror("division by zero")
yyerror("division by zero")
v.U.(*Mpflt).SetFloat64(1.0)
break
}
......@@ -1002,7 +995,7 @@ func evconst(n *Node) {
// which is not quite an ideal error.
case OMOD_ | CTFLT_:
if n.Diag == 0 {
Yyerror("illegal constant expression: floating-point %% operation")
yyerror("illegal constant expression: floating-point %% operation")
n.Diag = 1
}
......@@ -1021,7 +1014,7 @@ func evconst(n *Node) {
case ODIV_ | CTCPLX_:
if rv.U.(*Mpcplx).Real.CmpFloat64(0) == 0 && rv.U.(*Mpcplx).Imag.CmpFloat64(0) == 0 {
Yyerror("complex division by zero")
yyerror("complex division by zero")
rv.U.(*Mpcplx).Real.SetFloat64(1.0)
rv.U.(*Mpcplx).Imag.SetFloat64(0.0)
break
......@@ -1209,7 +1202,7 @@ ret:
return
settrue:
nn = Nodbool(true)
nn = nodbool(true)
nn.Orig = saveorig(n)
if !iscmp[n.Op] {
nn.Type = nl.Type
......@@ -1218,7 +1211,7 @@ settrue:
return
setfalse:
nn = Nodbool(false)
nn = nodbool(false)
nn.Orig = saveorig(n)
if !iscmp[n.Op] {
nn.Type = nl.Type
......@@ -1228,7 +1221,7 @@ setfalse:
illegal:
if n.Diag == 0 {
Yyerror("illegal constant expression: %v %v %v", nl.Type, n.Op, nr.Type)
yyerror("illegal constant expression: %v %v %v", nl.Type, n.Op, nr.Type)
n.Diag = 1
}
}
......@@ -1369,7 +1362,7 @@ func defaultlitreuse(n *Node, t *Type, reuse canReuseNode) *Node {
if n.Val().Ctype() == CTNIL {
lineno = lno
if n.Diag == 0 {
Yyerror("use of untyped nil")
yyerror("use of untyped nil")
n.Diag = 1
}
......@@ -1383,7 +1376,7 @@ func defaultlitreuse(n *Node, t *Type, reuse canReuseNode) *Node {
break
}
Yyerror("defaultlit: unknown literal: %v", n)
yyerror("defaultlit: unknown literal: %v", n)
case CTxxx:
Fatalf("defaultlit: idealkind is CTxxx: %+v", n)
......
......@@ -106,7 +106,7 @@ func testdclstack() {
if nerrors != 0 {
errorexit()
}
Yyerror("mark left on the stack")
yyerror("mark left on the stack")
}
}
}
......@@ -121,7 +121,7 @@ func redeclare(s *Sym, where string) {
tmp = s.Pkg.Path
}
pkgstr := tmp
Yyerror("%v redeclared %s\n"+
yyerror("%v redeclared %s\n"+
"\tprevious declaration during import %q", s, where, pkgstr)
} else {
line1 := lineno
......@@ -167,11 +167,11 @@ func declare(n *Node, ctxt Class) {
// kludgy: typecheckok means we're past parsing. Eg genwrapper may declare out of package names later.
if importpkg == nil && !typecheckok && s.Pkg != localpkg {
Yyerror("cannot declare name %v", s)
yyerror("cannot declare name %v", s)
}
if ctxt == PEXTERN && s.Name == "init" {
Yyerror("cannot declare init - must be func")
yyerror("cannot declare init - must be func")
}
gen := 0
......@@ -255,7 +255,7 @@ func variter(vl []*Node, t *Node, el []*Node) []*Node {
var e *Node
if doexpr {
if len(el) == 0 {
Yyerror("missing expression in var declaration")
yyerror("missing expression in var declaration")
break
}
e = el[0]
......@@ -279,7 +279,7 @@ func variter(vl []*Node, t *Node, el []*Node) []*Node {
}
if len(el) != 0 {
Yyerror("extra expression in var declaration")
yyerror("extra expression in var declaration")
}
return init
}
......@@ -290,7 +290,7 @@ func constiter(vl []*Node, t *Node, cl []*Node) []*Node {
lno := int32(0) // default is to leave line number alone in listtreecopy
if len(cl) == 0 {
if t != nil {
Yyerror("const declaration cannot have type without expression")
yyerror("const declaration cannot have type without expression")
}
cl = lastconst
t = lasttype
......@@ -304,7 +304,7 @@ func constiter(vl []*Node, t *Node, cl []*Node) []*Node {
var vv []*Node
for _, v := range vl {
if len(clcopy) == 0 {
Yyerror("missing value in const declaration")
yyerror("missing value in const declaration")
break
}
......@@ -321,7 +321,7 @@ func constiter(vl []*Node, t *Node, cl []*Node) []*Node {
}
if len(clcopy) != 0 {
Yyerror("extra expression in const declaration")
yyerror("extra expression in const declaration")
}
iota_ += 1
return vv
......@@ -504,7 +504,7 @@ func ifacedcl(n *Node) {
}
if isblank(n.Left) {
Yyerror("methods must have a unique non-blank name")
yyerror("methods must have a unique non-blank name")
}
n.Func = new(Func)
......@@ -603,7 +603,7 @@ func funcargs(nt *Node) {
if n.Left == nil {
// Name so that escape analysis can track it. ~r stands for 'result'.
n.Left = newname(LookupN("~r", gen))
n.Left = newname(lookupN("~r", gen))
gen++
}
......@@ -621,7 +621,7 @@ func funcargs(nt *Node) {
// Having multiple names causes too much confusion in later passes.
nn := *n.Left
nn.Orig = &nn
nn.Sym = LookupN("~b", gen)
nn.Sym = lookupN("~b", gen)
gen++
n.Left = &nn
}
......@@ -726,12 +726,12 @@ func checkembeddedtype(t *Type) {
if t.Sym == nil && t.IsPtr() {
t = t.Elem()
if t.IsInterface() {
Yyerror("embedded type cannot be a pointer to interface")
yyerror("embedded type cannot be a pointer to interface")
}
}
if t.IsPtr() || t.IsUnsafePtr() {
Yyerror("embedded type cannot be a pointer")
yyerror("embedded type cannot be a pointer")
} else if t.Etype == TFORW && t.ForwardType().Embedlineno == 0 {
t.ForwardType().Embedlineno = lineno
}
......@@ -770,7 +770,7 @@ func structfield(n *Node) *Field {
case string:
f.Note = u
default:
Yyerror("field annotation must be string")
yyerror("field annotation must be string")
case nil:
// noop
}
......@@ -798,7 +798,7 @@ func checkdupfields(what string, ts ...*Type) {
}
if seen[f.Sym] {
lineno = f.Nname.Lineno
Yyerror("duplicate %s %s", what, f.Sym.Name)
yyerror("duplicate %s %s", what, f.Sym.Name)
continue
}
seen[f.Sym] = true
......@@ -869,7 +869,7 @@ func interfacefield(n *Node) *Field {
}
if n.Val().Ctype() != CTxxx {
Yyerror("interface method cannot have annotation")
yyerror("interface method cannot have annotation")
}
f := newField()
......@@ -904,11 +904,11 @@ func interfacefield(n *Node) *Field {
break
case TFORW:
Yyerror("interface type loop involving %v", n.Type)
yyerror("interface type loop involving %v", n.Type)
f.Broke = true
default:
Yyerror("interface contains embedded non-interface %v", n.Type)
yyerror("interface contains embedded non-interface %v", n.Type)
f.Broke = true
}
}
......@@ -984,7 +984,7 @@ func embedded(s *Sym, pkg *Pkg) *Node {
var n *Node
if exportname(name) {
n = newname(Lookup(name))
n = newname(lookup(name))
} else if s.Pkg == builtinpkg {
// The name of embedded builtins belongs to pkg.
n = newname(Pkglookup(name, pkg))
......@@ -997,7 +997,7 @@ func embedded(s *Sym, pkg *Pkg) *Node {
}
func fakethis() *Node {
n := Nod(ODCLFIELD, nil, typenod(Ptrto(typ(TSTRUCT))))
n := Nod(ODCLFIELD, nil, typenod(ptrto(typ(TSTRUCT))))
return n
}
......@@ -1084,7 +1084,7 @@ func methodsym(nsym *Sym, t0 *Type, iface int) *Sym {
// if t0 == *t and t0 has a sym,
// we want to see *t, not t0, in the method name.
if t != t0 && t0.Sym != nil {
t0 = Ptrto(t)
t0 = ptrto(t)
}
suffix = ""
......@@ -1121,7 +1121,7 @@ func methodsym(nsym *Sym, t0 *Type, iface int) *Sym {
return s
bad:
Yyerror("illegal receiver type: %v", t0)
yyerror("illegal receiver type: %v", t0)
return nil
}
......@@ -1144,7 +1144,7 @@ func methodname(n *Node, t *Node) *Node {
}
if exportname(t.Sym.Name) {
n = newfuncname(Lookup(p))
n = newfuncname(lookup(p))
} else {
n = newfuncname(Pkglookup(p, t.Sym.Pkg))
}
......@@ -1164,7 +1164,7 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
// get parent type sym
rf := t.Recv() // ptr to this structure
if rf == nil {
Yyerror("missing receiver")
yyerror("missing receiver")
return
}
......@@ -1174,7 +1174,7 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
t := pa
if t != nil && t.IsPtr() {
if t.Sym != nil {
Yyerror("invalid receiver type %v (%v is a pointer type)", pa, t)
yyerror("invalid receiver type %v (%v is a pointer type)", pa, t)
return
}
t = t.Elem()
......@@ -1184,21 +1184,21 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
case t == nil || t.Broke:
// rely on typecheck having complained before
case t.Sym == nil:
Yyerror("invalid receiver type %v (%v is an unnamed type)", pa, t)
yyerror("invalid receiver type %v (%v is an unnamed type)", pa, t)
case t.IsPtr():
Yyerror("invalid receiver type %v (%v is a pointer type)", pa, t)
yyerror("invalid receiver type %v (%v is a pointer type)", pa, t)
case t.IsInterface():
Yyerror("invalid receiver type %v (%v is an interface type)", pa, t)
yyerror("invalid receiver type %v (%v is an interface type)", pa, t)
default:
// Should have picked off all the reasons above,
// but just in case, fall back to generic error.
Yyerror("invalid receiver type %v (%L / %L)", pa, pa, t)
yyerror("invalid receiver type %v (%L / %L)", pa, pa, t)
}
return
}
if local && !mt.Local {
Yyerror("cannot define new methods on non-local type %v", mt)
yyerror("cannot define new methods on non-local type %v", mt)
return
}
......@@ -1209,7 +1209,7 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
if mt.IsStruct() {
for _, f := range mt.Fields().Slice() {
if f.Sym == msym {
Yyerror("type %v has both field and method named %v", mt, msym)
yyerror("type %v has both field and method named %v", mt, msym)
return
}
}
......@@ -1225,7 +1225,7 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
// eqtype only checks that incoming and result parameters match,
// so explicitly check that the receiver parameters match too.
if !eqtype(t, f.Type) || !eqtype(t.Recv().Type, f.Type.Recv().Type) {
Yyerror("method redeclared: %v.%v\n\t%v\n\t%v", mt, msym, f.Type, t)
yyerror("method redeclared: %v.%v\n\t%v\n\t%v", mt, msym, f.Type, t)
}
return
}
......
......@@ -451,7 +451,7 @@ func escAnalyze(all []*Node, recursive bool) {
e.theSink.Op = ONAME
e.theSink.Orig = &e.theSink
e.theSink.Class = PEXTERN
e.theSink.Sym = Lookup(".sink")
e.theSink.Sym = lookup(".sink")
e.nodeEscState(&e.theSink).Escloopdepth = -1
e.recursive = recursive
......@@ -1097,7 +1097,7 @@ func escassign(e *EscState, dst, src *Node, step *EscStep) {
a := Nod(OADDR, src, nil)
a.Lineno = src.Lineno
e.nodeEscState(a).Escloopdepth = e.nodeEscState(src).Escloopdepth
a.Type = Ptrto(src.Type)
a.Type = ptrto(src.Type)
escflows(e, dst, a, e.stepAssign(nil, originalDst, src, dstwhy))
// Flowing multiple returns to a single dst happens when
......@@ -1392,7 +1392,7 @@ func initEscretval(e *EscState, n *Node, fntype *Type) {
src := Nod(ONAME, nil, nil)
buf := fmt.Sprintf(".out%d", i)
i++
src.Sym = Lookup(buf)
src.Sym = lookup(buf)
src.Type = t.Type
src.Class = PAUTO
src.Name.Curfn = Curfn
......@@ -1502,7 +1502,7 @@ func esccall(e *EscState, n *Node, up *Node) {
// Introduce ODDDARG node to represent ... allocation.
src = Nod(ODDDARG, nil, nil)
arr := typArray(n2.Type.Elem(), int64(len(lls)))
src.Type = Ptrto(arr) // make pointer so it will be tracked
src.Type = ptrto(arr) // make pointer so it will be tracked
src.Lineno = n.Lineno
e.track(src)
n.Right = src
......@@ -1558,7 +1558,7 @@ func esccall(e *EscState, n *Node, up *Node) {
note := ""
i := 0
lls := ll.Slice()
for t, it := IterFields(fntype.Params()); i < len(lls); i++ {
for t, it := iterFields(fntype.Params()); i < len(lls); i++ {
src = lls[i]
note = t.Note
if t.Isddd && !n.Isddd {
......@@ -1566,7 +1566,7 @@ func esccall(e *EscState, n *Node, up *Node) {
src = Nod(ODDDARG, nil, nil)
src.Lineno = n.Lineno
arr := typArray(t.Type.Elem(), int64(len(lls)-i))
src.Type = Ptrto(arr) // make pointer so it will be tracked
src.Type = ptrto(arr) // make pointer so it will be tracked
e.track(src)
n.Right = src
}
......
......@@ -35,7 +35,7 @@ func exportsym(n *Node) {
}
if n.Sym.Flags&(SymExport|SymPackage) != 0 {
if n.Sym.Flags&SymPackage != 0 {
Yyerror("export/package mismatch: %v", n.Sym)
yyerror("export/package mismatch: %v", n.Sym)
}
return
}
......@@ -291,7 +291,7 @@ func pkgtype(s *Sym) *Type {
}
if s.Def.Type == nil {
Yyerror("pkgtype %v", s)
yyerror("pkgtype %v", s)
}
return s.Def.Type
}
......@@ -306,7 +306,7 @@ func importconst(s *Sym, t *Type, n *Node) {
}
if n.Op != OLITERAL {
Yyerror("expression must be a constant")
yyerror("expression must be a constant")
return
}
......@@ -331,7 +331,7 @@ func importvar(s *Sym, t *Type) {
if eqtype(t, s.Def.Type) {
return
}
Yyerror("inconsistent definition for var %v during import\n\t%v (in %q)\n\t%v (in %q)", s, s.Def.Type, s.Importdef.Path, t, importpkg.Path)
yyerror("inconsistent definition for var %v during import\n\t%v (in %q)\n\t%v (in %q)", s, s.Def.Type, s.Importdef.Path, t, importpkg.Path)
}
n := newname(s)
......
......@@ -738,7 +738,7 @@ func (t *Type) typefmt(flag FmtFlag) string {
return "map.iter[" + m.Key().String() + "]" + m.Val().String()
}
Yyerror("unknown internal map type")
yyerror("unknown internal map type")
}
buf := make([]byte, 0, 64)
......@@ -752,7 +752,7 @@ func (t *Type) typefmt(flag FmtFlag) string {
if i != 0 {
buf = append(buf, ", "...)
}
buf = append(buf, Fldconv(f, flag1)...)
buf = append(buf, fldconv(f, flag1)...)
}
buf = append(buf, ')')
} else {
......@@ -762,7 +762,7 @@ func (t *Type) typefmt(flag FmtFlag) string {
buf = append(buf, ';')
}
buf = append(buf, ' ')
buf = append(buf, Fldconv(f, FmtLong)...)
buf = append(buf, fldconv(f, FmtLong)...)
}
if t.NumFields() != 0 {
buf = append(buf, ' ')
......@@ -1600,7 +1600,7 @@ func (t *Type) String() string {
return t.tconv(0)
}
func Fldconv(f *Field, flag FmtFlag) string {
func fldconv(f *Field, flag FmtFlag) string {
if f == nil {
return "<T>"
}
......@@ -1628,7 +1628,7 @@ func Fldconv(f *Field, flag FmtFlag) string {
if s.Name[1] == 'r' { // originally an unnamed result
s = nil
} else if s.Name[1] == 'b' { // originally the blank identifier _
s = Lookup("_")
s = lookup("_")
}
}
} else {
......
......@@ -105,7 +105,7 @@ func moveToHeap(n *Node) {
Dump("MOVE", n)
}
if compiling_runtime {
Yyerror("%v escapes to heap, not allowed in runtime.", n)
yyerror("%v escapes to heap, not allowed in runtime.", n)
}
if n.Class == PAUTOHEAP {
Dump("n", n)
......@@ -114,8 +114,8 @@ func moveToHeap(n *Node) {
// Allocate a local stack variable to hold the pointer to the heap copy.
// temp will add it to the function declaration list automatically.
heapaddr := temp(Ptrto(n.Type))
heapaddr.Sym = Lookup("&" + n.Sym.Name)
heapaddr := temp(ptrto(n.Type))
heapaddr.Sym = lookup("&" + n.Sym.Name)
heapaddr.Orig.Sym = heapaddr.Sym
// Parameters have a local stack copy used at function start/end
......@@ -200,13 +200,13 @@ func tempname(nn *Node, t *Type) {
}
if t == nil {
Yyerror("tempname called with nil type")
yyerror("tempname called with nil type")
t = Types[TINT32]
}
// give each tmp a different name so that there
// a chance to registerizer them
s := LookupN("autotmp_", statuniqgen)
s := lookupN("autotmp_", statuniqgen)
statuniqgen++
n := Nod(ONAME, nil, nil)
n.Sym = s
......
......@@ -286,7 +286,7 @@ func Naddr(a *obj.Addr, n *Node) {
a.Sym = Linksym(n.Sym)
a.Offset = n.Xoffset
if a.Offset != int64(int32(a.Offset)) {
Yyerror("offset %d too large for OINDREG", a.Offset)
yyerror("offset %d too large for OINDREG", a.Offset)
}
if Thearch.LinkArch.Family == sys.I386 { // TODO(rsc): Never clear a->width.
a.Width = 0
......@@ -317,7 +317,7 @@ func Naddr(a *obj.Addr, n *Node) {
//if(a->node >= (Node*)&n)
// fatal("stack node");
if s == nil {
s = Lookup(".noname")
s = lookup(".noname")
}
if n.Name.Method && n.Type != nil && n.Type.Sym != nil && n.Type.Sym.Pkg != nil {
s = Pkglookup(s.Name, n.Type.Sym.Pkg)
......@@ -503,7 +503,7 @@ func nodarg(t interface{}, fp int) *Node {
// Build fake variable name for whole arg struct.
n = Nod(ONAME, nil, nil)
n.Sym = Lookup(".args")
n.Sym = lookup(".args")
n.Type = t
first := t.Field(0)
if first == nil {
......@@ -566,7 +566,7 @@ func nodarg(t interface{}, fp int) *Node {
// or else the assignment to _ will be
// discarded during code generation.
if isblank(n) {
n.Sym = Lookup("__")
n.Sym = lookup("__")
}
switch fp {
......@@ -648,7 +648,7 @@ Switch:
break Switch
}
}
Flusherrors()
flusherrors()
regdump()
Fatalf("out of fixed registers")
......@@ -668,7 +668,7 @@ Switch:
break Switch
}
}
Flusherrors()
flusherrors()
regdump()
Fatalf("out of floating registers")
......
......@@ -27,7 +27,7 @@ var renameinit_initgen int
func renameinit() *Sym {
renameinit_initgen++
return LookupN("init.", renameinit_initgen)
return lookupN("init.", renameinit_initgen)
}
// hand-craft the following initialization code
......@@ -70,7 +70,7 @@ func anyinit(n []*Node) bool {
}
// is there an explicit init function
s := Lookup("init.1")
s := lookup("init.1")
if s.Def != nil {
return true
......@@ -101,14 +101,14 @@ func fninit(n []*Node) {
var r []*Node
// (1)
gatevar := newname(Lookup("initdone·"))
gatevar := newname(lookup("initdone·"))
addvar(gatevar, Types[TUINT8], PEXTERN)
// (2)
Maxarg = 0
fn := Nod(ODCLFUNC, nil, nil)
initsym := Lookup("init")
initsym := lookup("init")
fn.Func.Nname = newname(initsym)
fn.Func.Nname.Name.Defn = fn
fn.Func.Nname.Name.Param.Ntype = Nod(OTFUNC, nil, nil)
......@@ -153,7 +153,7 @@ func fninit(n []*Node) {
// (8)
// could check that it is fn of no args/returns
for i := 1; ; i++ {
s := LookupN("init.", i)
s := lookupN("init.", i)
if s.Def == nil {
break
}
......
......@@ -722,7 +722,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
}
} else {
// match arguments except final variadic (unless the call is dotted itself)
t, it := IterFields(fn.Type.Params())
t, it := iterFields(fn.Type.Params())
for t != nil {
if li >= n.List.Len() {
break
......@@ -870,7 +870,7 @@ func inlvar(var_ *Node) *Node {
// Synthesize a variable to store the inlined function's results in.
func retvar(t *Field, i int) *Node {
n := newname(LookupN("~r", i))
n := newname(lookupN("~r", i))
n.Type = t.Type
n.Class = PAUTO
n.Used = true
......@@ -882,7 +882,7 @@ func retvar(t *Field, i int) *Node {
// Synthesize a variable to store the inlined function's arguments
// when they come from a multiple return call.
func argvar(t *Type, i int) *Node {
n := newname(LookupN("~arg", i))
n := newname(lookupN("~arg", i))
n.Type = t.Elem()
n.Class = PAUTO
n.Used = true
......@@ -969,7 +969,7 @@ func (subst *inlsubst) node(n *Node) *Node {
*m = *n
m.Ninit.Set(nil)
p := fmt.Sprintf("%s·%d", n.Left.Sym.Name, inlgen)
m.Left = newname(Lookup(p))
m.Left = newname(lookup(p))
return m
default:
......
......@@ -76,7 +76,7 @@ const (
UintptrEscapes // pointers converted to uintptr escape
)
func PragmaValue(verb string) Pragma {
func pragmaValue(verb string) Pragma {
switch verb {
case "go:nointerface":
if obj.Fieldtrack_enabled != 0 {
......@@ -92,17 +92,17 @@ func PragmaValue(verb string) Pragma {
return Noinline
case "go:systemstack":
if !compiling_runtime {
Yyerror("//go:systemstack only allowed in runtime")
yyerror("//go:systemstack only allowed in runtime")
}
return Systemstack
case "go:nowritebarrier":
if !compiling_runtime {
Yyerror("//go:nowritebarrier only allowed in runtime")
yyerror("//go:nowritebarrier only allowed in runtime")
}
return Nowritebarrier
case "go:nowritebarrierrec":
if !compiling_runtime {
Yyerror("//go:nowritebarrierrec only allowed in runtime")
yyerror("//go:nowritebarrierrec only allowed in runtime")
}
return Nowritebarrierrec | Nowritebarrier // implies Nowritebarrier
case "go:cgo_unsafe_args":
......@@ -355,7 +355,7 @@ l0:
continue
}
if c == EOF {
Yyerror("eof in comment")
yyerror("eof in comment")
errorexit()
}
c = l.getr()
......@@ -520,7 +520,7 @@ l0:
default:
// anything else is illegal
Yyerror("syntax error: illegal character %#U", c)
yyerror("syntax error: illegal character %#U", c)
goto l0
}
......@@ -581,10 +581,10 @@ func (l *lexer) ident(c rune) {
if c >= utf8.RuneSelf {
if unicode.IsLetter(c) || c == '_' || unicode.IsDigit(c) {
if cp.Len() == 0 && unicode.IsDigit(c) {
Yyerror("identifier cannot begin with digit %#U", c)
yyerror("identifier cannot begin with digit %#U", c)
}
} else {
Yyerror("invalid identifier character %#U", c)
yyerror("invalid identifier character %#U", c)
}
cp.WriteRune(c)
} else if isLetter(c) || isDigit(c) {
......@@ -614,7 +614,7 @@ func (l *lexer) ident(c rune) {
}
}
s := LookupBytes(name)
s := lookupBytes(name)
if Debug['x'] != 0 {
fmt.Printf("lex: ident %v\n", s)
}
......@@ -686,7 +686,7 @@ func (l *lexer) number(c rune) {
c = l.getr()
}
if lexbuf.Len() == 2 {
Yyerror("malformed hex constant")
yyerror("malformed hex constant")
}
} else {
// decimal 0, octal, or float
......@@ -727,7 +727,7 @@ func (l *lexer) number(c rune) {
c = l.getr()
}
if !isDigit(c) {
Yyerror("malformed floating point constant exponent")
yyerror("malformed floating point constant exponent")
}
for isDigit(c) {
cp.WriteByte(byte(c))
......@@ -742,7 +742,7 @@ func (l *lexer) number(c rune) {
x.Real.SetFloat64(0.0)
x.Imag.SetString(str)
if x.Imag.Val.IsInf() {
Yyerror("overflow in imaginary constant")
yyerror("overflow in imaginary constant")
x.Imag.SetFloat64(0.0)
}
l.val.U = x
......@@ -758,14 +758,14 @@ func (l *lexer) number(c rune) {
if isInt {
if malformedOctal {
Yyerror("malformed octal constant")
yyerror("malformed octal constant")
}
str = lexbuf.String()
x := new(Mpint)
x.SetString(str)
if x.Ovf {
Yyerror("overflow in constant")
yyerror("overflow in constant")
x.SetInt64(0)
}
l.val.U = x
......@@ -780,7 +780,7 @@ func (l *lexer) number(c rune) {
x := newMpflt()
x.SetString(str)
if x.Val.IsInf() {
Yyerror("overflow in float constant")
yyerror("overflow in float constant")
x.SetFloat64(0.0)
}
l.val.U = x
......@@ -837,7 +837,7 @@ func (l *lexer) rawString() {
continue
}
if c == EOF {
Yyerror("eof in string")
yyerror("eof in string")
break
}
if c == '`' {
......@@ -858,7 +858,7 @@ func (l *lexer) rawString() {
func (l *lexer) rune() {
r, b, ok := l.onechar('\'')
if !ok {
Yyerror("empty character literal or unescaped ' in character literal")
yyerror("empty character literal or unescaped ' in character literal")
r = '\''
}
if r == 0 {
......@@ -866,7 +866,7 @@ func (l *lexer) rune() {
}
if c := l.getr(); c != '\'' {
Yyerror("missing '")
yyerror("missing '")
l.ungetr()
}
......@@ -929,16 +929,16 @@ func (l *lexer) getlinepragma() rune {
switch verb {
case "go:linkname":
if !imported_unsafe {
Yyerror("//go:linkname only allowed in Go files that import \"unsafe\"")
yyerror("//go:linkname only allowed in Go files that import \"unsafe\"")
}
f := strings.Fields(text)
if len(f) != 3 {
Yyerror("usage: //go:linkname localname linkname")
yyerror("usage: //go:linkname localname linkname")
break
}
Lookup(f[1]).Linkname = f[2]
lookup(f[1]).Linkname = f[2]
default:
l.pragma |= PragmaValue(verb)
l.pragma |= pragmaValue(verb)
}
return c
}
......@@ -984,7 +984,7 @@ func (l *lexer) getlinepragma() rune {
return c // todo: make this an error instead? it is almost certainly a bug.
}
if n > 1e8 {
Yyerror("line number out of range")
yyerror("line number out of range")
errorexit()
}
if n <= 0 {
......@@ -1012,7 +1012,7 @@ func pragcgo(text string) string {
return fmt.Sprintln(verb, local, remote)
default:
Yyerror(`usage: //go:%s local [remote]`, verb)
yyerror(`usage: //go:%s local [remote]`, verb)
}
case "cgo_import_dynamic":
switch {
......@@ -1032,7 +1032,7 @@ func pragcgo(text string) string {
return fmt.Sprintln(verb, local, remote, library)
default:
Yyerror(`usage: //go:cgo_import_dynamic local [remote ["library"]]`)
yyerror(`usage: //go:cgo_import_dynamic local [remote ["library"]]`)
}
case "cgo_import_static":
switch {
......@@ -1041,7 +1041,7 @@ func pragcgo(text string) string {
return fmt.Sprintln(verb, local)
default:
Yyerror(`usage: //go:cgo_import_static local`)
yyerror(`usage: //go:cgo_import_static local`)
}
case "cgo_dynamic_linker":
switch {
......@@ -1050,7 +1050,7 @@ func pragcgo(text string) string {
return fmt.Sprintln(verb, path)
default:
Yyerror(`usage: //go:cgo_dynamic_linker "path"`)
yyerror(`usage: //go:cgo_dynamic_linker "path"`)
}
case "cgo_ldflag":
switch {
......@@ -1059,7 +1059,7 @@ func pragcgo(text string) string {
return fmt.Sprintln(verb, arg)
default:
Yyerror(`usage: //go:cgo_ldflag "arg"`)
yyerror(`usage: //go:cgo_ldflag "arg"`)
}
}
return ""
......@@ -1143,12 +1143,12 @@ func (l *lexer) onechar(quote rune) (r rune, b byte, ok bool) {
c := l.getr()
switch c {
case EOF:
Yyerror("eof in string")
yyerror("eof in string")
l.ungetr()
return
case '\n':
Yyerror("newline in string")
yyerror("newline in string")
l.ungetr()
return
......@@ -1182,12 +1182,12 @@ func (l *lexer) onechar(quote rune) (r rune, b byte, ok bool) {
continue
}
Yyerror("non-octal character in escape sequence: %c", c)
yyerror("non-octal character in escape sequence: %c", c)
l.ungetr()
}
if x > 255 {
Yyerror("octal escape value > 255: %d", x)
yyerror("octal escape value > 255: %d", x)
}
return 0, byte(x), true
......@@ -1211,7 +1211,7 @@ func (l *lexer) onechar(quote rune) (r rune, b byte, ok bool) {
default:
if c != quote {
Yyerror("unknown escape sequence: %c", c)
yyerror("unknown escape sequence: %c", c)
}
}
......@@ -1221,7 +1221,7 @@ func (l *lexer) onechar(quote rune) (r rune, b byte, ok bool) {
func (l *lexer) unichar(n int) rune {
x := l.hexchar(n)
if x > utf8.MaxRune || 0xd800 <= x && x < 0xe000 {
Yyerror("invalid Unicode code point in escape sequence: %#x", x)
yyerror("invalid Unicode code point in escape sequence: %#x", x)
x = utf8.RuneError
}
return rune(x)
......@@ -1240,7 +1240,7 @@ func (l *lexer) hexchar(n int) uint32 {
case 'A' <= c && c <= 'F':
d = uint32(c - 'A' + 10)
default:
Yyerror("non-hex character in escape sequence: %c", c)
yyerror("non-hex character in escape sequence: %c", c)
l.ungetr()
return x
}
......
......@@ -106,7 +106,7 @@ func Main() {
defer hidePanic()
Ctxt = obj.Linknew(Thearch.LinkArch)
Ctxt.DiagFunc = Yyerror
Ctxt.DiagFunc = yyerror
Ctxt.Bso = bufio.NewWriter(os.Stdout)
localpkg = mkpkg("")
......@@ -506,7 +506,7 @@ func Main() {
errorexit()
}
Flusherrors()
flusherrors()
timings.Stop()
if benchfile != "" {
......@@ -631,7 +631,7 @@ func findpkg(name string) (file string, ok bool) {
// don't want to see "encoding/../encoding/base64"
// as different from "encoding/base64".
if q := path.Clean(name); q != name {
Yyerror("non-canonical import path %q (should be %q)", name, q)
yyerror("non-canonical import path %q (should be %q)", name, q)
return "", false
}
......@@ -698,12 +698,12 @@ func importfile(f *Val, indent []byte) {
path_, ok := f.U.(string)
if !ok {
Yyerror("import statement not a string")
yyerror("import statement not a string")
return
}
if len(path_) == 0 {
Yyerror("import path is empty")
yyerror("import path is empty")
return
}
......@@ -716,12 +716,12 @@ func importfile(f *Val, indent []byte) {
// the main package, just as we reserve the import
// path "math" to identify the standard math package.
if path_ == "main" {
Yyerror("cannot import \"main\"")
yyerror("cannot import \"main\"")
errorexit()
}
if myimportpath != "" && path_ == myimportpath {
Yyerror("import %q while compiling that package (import cycle)", path_)
yyerror("import %q while compiling that package (import cycle)", path_)
errorexit()
}
......@@ -731,7 +731,7 @@ func importfile(f *Val, indent []byte) {
if path_ == "unsafe" {
if safemode {
Yyerror("cannot import package unsafe")
yyerror("cannot import package unsafe")
errorexit()
}
......@@ -742,7 +742,7 @@ func importfile(f *Val, indent []byte) {
if islocalname(path_) {
if path_[0] == '/' {
Yyerror("import path cannot be absolute path")
yyerror("import path cannot be absolute path")
return
}
......@@ -759,7 +759,7 @@ func importfile(f *Val, indent []byte) {
file, found := findpkg(path_)
if !found {
Yyerror("can't find import: %q", path_)
yyerror("can't find import: %q", path_)
errorexit()
}
......@@ -773,7 +773,7 @@ func importfile(f *Val, indent []byte) {
impf, err := os.Open(file)
if err != nil {
Yyerror("can't open import: %q: %v", path_, err)
yyerror("can't open import: %q: %v", path_, err)
errorexit()
}
defer impf.Close()
......@@ -781,7 +781,7 @@ func importfile(f *Val, indent []byte) {
if strings.HasSuffix(file, ".a") {
if !skiptopkgdef(imp) {
Yyerror("import %s: not a package file", file)
yyerror("import %s: not a package file", file)
errorexit()
}
}
......@@ -797,13 +797,13 @@ func importfile(f *Val, indent []byte) {
if p != "empty archive" {
if !strings.HasPrefix(p, "go object ") {
Yyerror("import %s: not a go object file: %s", file, p)
yyerror("import %s: not a go object file: %s", file, p)
errorexit()
}
q := fmt.Sprintf("%s %s %s %s", obj.GOOS, obj.GOARCH, obj.Version, obj.Expstring())
if p[10:] != q {
Yyerror("import %s: object is [%s] expected [%s]", file, p[10:], q)
yyerror("import %s: object is [%s] expected [%s]", file, p[10:], q)
errorexit()
}
}
......@@ -824,7 +824,7 @@ func importfile(f *Val, indent []byte) {
}
}
if safemode && !safe {
Yyerror("cannot import unsafe package %q", importpkg.Path)
yyerror("cannot import unsafe package %q", importpkg.Path)
}
// assume files move (get installed)
......@@ -857,7 +857,7 @@ func importfile(f *Val, indent []byte) {
switch c {
case '\n':
Yyerror("cannot import %s: old export format no longer supported (recompile library)", path_)
yyerror("cannot import %s: old export format no longer supported (recompile library)", path_)
case 'B':
if Debug_export != 0 {
......@@ -867,7 +867,7 @@ func importfile(f *Val, indent []byte) {
Import(imp)
default:
Yyerror("no import in %q", path_)
yyerror("no import in %q", path_)
errorexit()
}
}
......@@ -893,12 +893,12 @@ func pkgnotused(lineno int32, path string, name string) {
func mkpackage(pkgname string) {
if localpkg.Name == "" {
if pkgname == "_" {
Yyerror("invalid package name _")
yyerror("invalid package name _")
}
localpkg.Name = pkgname
} else {
if pkgname != localpkg.Name {
Yyerror("package %s; expected %s", pkgname, localpkg.Name)
yyerror("package %s; expected %s", pkgname, localpkg.Name)
}
for _, s := range localpkg.Syms {
if s.Def == nil {
......
......@@ -128,7 +128,7 @@ func (a *Mpflt) Float64() float64 {
// check for overflow
if math.IsInf(x, 0) && nsavederrors+nerrors == 0 {
Yyerror("mpgetflt ovf")
yyerror("mpgetflt ovf")
}
return x + 0 // avoid -0 (should not be needed, but be conservative)
......@@ -140,7 +140,7 @@ func (a *Mpflt) Float32() float64 {
// check for overflow
if math.IsInf(x, 0) && nsavederrors+nerrors == 0 {
Yyerror("mpgetflt32 ovf")
yyerror("mpgetflt32 ovf")
}
return x + 0 // avoid -0 (should not be needed, but be conservative)
......@@ -187,13 +187,13 @@ func (a *Mpflt) SetString(as string) {
// - constant exponent out of range
// - decimal point and binary point in constant
// TODO(gri) use different conversion function or check separately
Yyerror("malformed constant: %s", as)
yyerror("malformed constant: %s", as)
a.Val.SetFloat64(0)
return
}
if f.IsInf() {
Yyerror("constant too large: %s", as)
yyerror("constant too large: %s", as)
a.Val.SetFloat64(0)
return
}
......
......@@ -71,7 +71,7 @@ func (a *Mpint) SetFloat(b *Mpflt) int {
func (a *Mpint) Add(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpaddfixfix")
yyerror("ovf in mpaddfixfix")
}
a.SetOverflow()
return
......@@ -80,14 +80,14 @@ func (a *Mpint) Add(b *Mpint) {
a.Val.Add(&a.Val, &b.Val)
if a.checkOverflow(0) {
Yyerror("constant addition overflow")
yyerror("constant addition overflow")
}
}
func (a *Mpint) Sub(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpsubfixfix")
yyerror("ovf in mpsubfixfix")
}
a.SetOverflow()
return
......@@ -96,14 +96,14 @@ func (a *Mpint) Sub(b *Mpint) {
a.Val.Sub(&a.Val, &b.Val)
if a.checkOverflow(0) {
Yyerror("constant subtraction overflow")
yyerror("constant subtraction overflow")
}
}
func (a *Mpint) Mul(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpmulfixfix")
yyerror("ovf in mpmulfixfix")
}
a.SetOverflow()
return
......@@ -112,14 +112,14 @@ func (a *Mpint) Mul(b *Mpint) {
a.Val.Mul(&a.Val, &b.Val)
if a.checkOverflow(0) {
Yyerror("constant multiplication overflow")
yyerror("constant multiplication overflow")
}
}
func (a *Mpint) Quo(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpdivfixfix")
yyerror("ovf in mpdivfixfix")
}
a.SetOverflow()
return
......@@ -129,14 +129,14 @@ func (a *Mpint) Quo(b *Mpint) {
if a.checkOverflow(0) {
// can only happen for div-0 which should be checked elsewhere
Yyerror("constant division overflow")
yyerror("constant division overflow")
}
}
func (a *Mpint) Rem(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpmodfixfix")
yyerror("ovf in mpmodfixfix")
}
a.SetOverflow()
return
......@@ -146,14 +146,14 @@ func (a *Mpint) Rem(b *Mpint) {
if a.checkOverflow(0) {
// should never happen
Yyerror("constant modulo overflow")
yyerror("constant modulo overflow")
}
}
func (a *Mpint) Or(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mporfixfix")
yyerror("ovf in mporfixfix")
}
a.SetOverflow()
return
......@@ -165,7 +165,7 @@ func (a *Mpint) Or(b *Mpint) {
func (a *Mpint) And(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpandfixfix")
yyerror("ovf in mpandfixfix")
}
a.SetOverflow()
return
......@@ -177,7 +177,7 @@ func (a *Mpint) And(b *Mpint) {
func (a *Mpint) AndNot(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpandnotfixfix")
yyerror("ovf in mpandnotfixfix")
}
a.SetOverflow()
return
......@@ -189,7 +189,7 @@ func (a *Mpint) AndNot(b *Mpint) {
func (a *Mpint) Xor(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpxorfixfix")
yyerror("ovf in mpxorfixfix")
}
a.SetOverflow()
return
......@@ -201,7 +201,7 @@ func (a *Mpint) Xor(b *Mpint) {
func (a *Mpint) Lsh(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mplshfixfix")
yyerror("ovf in mplshfixfix")
}
a.SetOverflow()
return
......@@ -213,13 +213,13 @@ func (a *Mpint) Lsh(b *Mpint) {
if s < 0 {
msg = "invalid negative shift count"
}
Yyerror("%s: %d", msg, s)
yyerror("%s: %d", msg, s)
a.SetInt64(0)
return
}
if a.checkOverflow(int(s)) {
Yyerror("constant shift overflow")
yyerror("constant shift overflow")
return
}
a.Val.Lsh(&a.Val, uint(s))
......@@ -228,7 +228,7 @@ func (a *Mpint) Lsh(b *Mpint) {
func (a *Mpint) Rsh(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mprshfixfix")
yyerror("ovf in mprshfixfix")
}
a.SetOverflow()
return
......@@ -236,7 +236,7 @@ func (a *Mpint) Rsh(b *Mpint) {
s := b.Int64()
if s < 0 {
Yyerror("invalid negative shift count: %d", s)
yyerror("invalid negative shift count: %d", s)
if a.Val.Sign() < 0 {
a.SetInt64(-1)
} else {
......@@ -266,7 +266,7 @@ func (a *Mpint) Neg() {
func (a *Mpint) Int64() int64 {
if a.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("constant overflow")
yyerror("constant overflow")
}
return 0
}
......@@ -288,12 +288,12 @@ func (a *Mpint) SetString(as string) {
// - malformed octal constant
// - malformed decimal constant
// TODO(gri) use different conversion function
Yyerror("malformed integer constant: %s", as)
yyerror("malformed integer constant: %s", as)
a.Val.SetUint64(0)
return
}
if a.checkOverflow(0) {
Yyerror("constant too large: %s", as)
yyerror("constant too large: %s", as)
}
}
......
......@@ -119,7 +119,7 @@ func (p *noder) importDecl(imp *syntax.ImportDecl) {
if imp.LocalPkgName != nil {
my = p.name(imp.LocalPkgName)
} else {
my = Lookup(ipkg.Name)
my = lookup(ipkg.Name)
}
pack := p.nod(imp, OPACK, nil, nil)
......@@ -222,7 +222,7 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
f.Nbody.Set(body)
f.Noescape = pragma&Noescape != 0
if f.Noescape && len(body) != 0 {
Yyerror("can only use //go:noescape with external func implementations")
yyerror("can only use //go:noescape with external func implementations")
}
f.Func.Pragma = pragma
lineno = p.baseline + int32(fun.EndLine) - 1
......@@ -243,13 +243,13 @@ func (p *noder) funcHeader(fun *syntax.FuncDecl) *Node {
if name.Name == "init" {
name = renameinit()
if t.List.Len() > 0 || t.Rlist.Len() > 0 {
Yyerror("func init must have no arguments and no return values")
yyerror("func init must have no arguments and no return values")
}
}
if localpkg.Name == "main" && name.Name == "main" {
if t.List.Len() > 0 || t.Rlist.Len() > 0 {
Yyerror("func main must have no arguments and no return values")
yyerror("func main must have no arguments and no return values")
}
}
......@@ -300,9 +300,9 @@ func (p *noder) param(param *syntax.Field, dddOk, final bool) *Node {
// rewrite ...T parameter
if typ.Op == ODDD {
if !dddOk {
Yyerror("cannot use ... in receiver or result parameter list")
yyerror("cannot use ... in receiver or result parameter list")
} else if !final {
Yyerror("can only use ... with final parameter in list")
yyerror("can only use ... with final parameter in list")
}
typ.Op = OTARRAY
typ.Right = typ.Left
......@@ -371,7 +371,7 @@ func (p *noder) expr(expr syntax.Expr) *Node {
obj.Used = true
return oldname(s)
}
return p.setlineno(expr, NodSym(OXDOT, obj, sel))
return p.setlineno(expr, nodSym(OXDOT, obj, sel))
case *syntax.IndexExpr:
return p.nod(expr, OINDEX, p.expr(expr.X), p.expr(expr.Index))
case *syntax.SliceExpr:
......@@ -449,7 +449,7 @@ func (p *noder) expr(expr syntax.Expr) *Node {
if expr.Lhs != nil {
n.Left = p.declName(expr.Lhs)
if isblank(n.Left) {
Yyerror("invalid variable name %v in type switch", n.Left)
yyerror("invalid variable name %v in type switch", n.Left)
}
}
return n
......@@ -530,7 +530,7 @@ func (p *noder) packname(expr syntax.Expr) *Sym {
s := p.name(expr.Sel)
var pkg *Pkg
if name.Def == nil || name.Def.Op != OPACK {
Yyerror("%v is not a package", name)
yyerror("%v is not a package", name)
pkg = localpkg
} else {
name.Def.Used = true
......@@ -666,7 +666,7 @@ func (p *noder) stmt(stmt syntax.Stmt) *Node {
break
}
if ln.Sym.Def != ln {
Yyerror("%s is shadowed during return", ln.Sym.Name)
yyerror("%s is shadowed during return", ln.Sym.Name)
}
}
}
......@@ -948,7 +948,7 @@ func (p *noder) basicLit(lit *syntax.BasicLit) Val {
}
func (p *noder) name(name *syntax.Name) *Sym {
return Lookup(name.Value)
return lookup(name.Value)
}
func (p *noder) mkname(name *syntax.Name) *Node {
......@@ -1034,7 +1034,7 @@ func (p *noder) pragma(pos, line int, text string) syntax.Pragma {
p.error(pos, line, "usage: //go:linkname localname linkname")
break
}
Lookup(f[1]).Linkname = f[2]
lookup(f[1]).Linkname = f[2]
case strings.HasPrefix(text, "go:cgo_"):
pragcgobuf += pragcgo(text)
......@@ -1044,7 +1044,7 @@ func (p *noder) pragma(pos, line int, text string) syntax.Pragma {
if i := strings.Index(text, " "); i >= 0 {
verb = verb[:i]
}
return syntax.Pragma(PragmaValue(verb))
return syntax.Pragma(pragmaValue(verb))
}
return 0
......
......@@ -53,7 +53,7 @@ func dumpobj1(outfile string, mode int) {
var err error
bout, err = bio.Create(outfile)
if err != nil {
Flusherrors()
flusherrors()
fmt.Printf("can't create %s: %v\n", outfile, err)
errorexit()
}
......
......@@ -363,7 +363,7 @@ func ordercall(n *Node, order *Order) {
ordercallargs(&n.List, order)
if n.Op == OCALLFUNC {
t, it := IterFields(n.Left.Type.Params())
t, it := iterFields(n.Left.Type.Params())
for i := range n.List.Slice() {
// Check for "unsafe-uintptr" tag provided by escape analysis.
// If present and the argument is really a pointer being converted
......@@ -815,7 +815,7 @@ func orderstmt(n *Node, order *Order) {
if r != nil {
switch r.Op {
default:
Yyerror("unknown op in select %v", r.Op)
yyerror("unknown op in select %v", r.Op)
Dump("select case", r)
// If this is case x := <-ch or case x, y := <-ch, the case has
......@@ -837,7 +837,7 @@ func orderstmt(n *Node, order *Order) {
}
if r.Ninit.Len() != 0 {
Yyerror("ninit on select recv")
yyerror("ninit on select recv")
dumplist("ninit", r.Ninit)
}
......@@ -899,7 +899,7 @@ func orderstmt(n *Node, order *Order) {
case OSEND:
if r.Ninit.Len() != 0 {
Yyerror("ninit on select send")
yyerror("ninit on select send")
dumplist("ninit", r.Ninit)
}
......
......@@ -93,7 +93,7 @@ func (p *parser) syntax_error(msg string) {
msg = ", " + msg
default:
// plain error - we don't care about current token
Yyerror("syntax error: %s", msg)
yyerror("syntax error: %s", msg)
return
}
......@@ -121,7 +121,7 @@ func (p *parser) syntax_error(msg string) {
tok = tokstring(p.tok)
}
Yyerror("syntax error: unexpected %s", tok+msg)
yyerror("syntax error: unexpected %s", tok+msg)
}
// Like syntax_error, but reports error at given line rather than current lexer line.
......@@ -328,7 +328,7 @@ func (p *parser) importdcl() {
case '.':
// import into my name space
my = Lookup(".")
my = lookup(".")
p.next()
}
......@@ -358,7 +358,7 @@ func (p *parser) importdcl() {
ipkg.Direct = true
if my == nil {
my = Lookup(ipkg.Name)
my = lookup(ipkg.Name)
}
pack := Nod(OPACK, nil, nil)
......@@ -372,7 +372,7 @@ func (p *parser) importdcl() {
}
if my.Name == "init" {
lineno = line
Yyerror("cannot import package as init - init must be a func")
yyerror("cannot import package as init - init must be a func")
return
}
if my.Name == "_" {
......@@ -607,12 +607,12 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
if rhs[0].Op == OTYPESW {
ts := Nod(OTYPESW, nil, rhs[0].Right)
if len(rhs) > 1 {
Yyerror("expr.(type) must be alone in list")
yyerror("expr.(type) must be alone in list")
}
if len(lhs) > 1 {
Yyerror("argument count mismatch: %d = %d", len(lhs), 1)
yyerror("argument count mismatch: %d = %d", len(lhs), 1)
} else if (lhs[0].Op != ONAME && lhs[0].Op != OTYPE && lhs[0].Op != ONONAME && (lhs[0].Op != OLITERAL || lhs[0].Name == nil)) || isblank(lhs[0]) {
Yyerror("invalid variable name %v in type switch", lhs[0])
yyerror("invalid variable name %v in type switch", lhs[0])
} else {
ts.Left = dclname(lhs[0].Sym)
} // it's a colas, so must not re-use an oldname
......@@ -866,7 +866,7 @@ func (p *parser) for_header() *Node {
if init != nil || post != nil {
// init ; test ; incr
if post != nil && post.Colas {
Yyerror("cannot declare in the for-increment")
yyerror("cannot declare in the for-increment")
}
h := Nod(OFOR, nil, nil)
if init != nil {
......@@ -932,7 +932,7 @@ func (p *parser) header(for_stmt bool) (init, cond, post *Node) {
// accept potential vardcl but complain
// (for test/syntax/forvar.go)
if for_stmt && p.tok == LVAR {
Yyerror("var declaration not allowed in for initializer")
yyerror("var declaration not allowed in for initializer")
p.next()
}
init = p.simple_stmt(false, for_stmt)
......@@ -992,7 +992,7 @@ func (p *parser) if_stmt() *Node {
stmt := p.if_header()
if stmt.Left == nil {
Yyerror("missing condition in if statement")
yyerror("missing condition in if statement")
}
stmt.Nbody.Set(p.loop_body("if clause"))
......@@ -1192,10 +1192,10 @@ func (p *parser) pseudocall() *Node {
case OCALL:
return x
case OPAREN:
Yyerror("expression in go/defer must not be parenthesized")
yyerror("expression in go/defer must not be parenthesized")
// already progressed, no need to advance
default:
Yyerror("expression in go/defer must be function call")
yyerror("expression in go/defer must be function call")
// already progressed, no need to advance
}
return nil
......@@ -1365,7 +1365,7 @@ loop:
case 0:
i := index[0]
if i == nil {
Yyerror("missing index in index expression")
yyerror("missing index in index expression")
}
x = Nod(OINDEX, x, i)
case 1:
......@@ -1373,10 +1373,10 @@ loop:
x.SetSliceBounds(index[0], index[1], nil)
case 2:
if index[1] == nil {
Yyerror("middle index required in 3-index slice")
yyerror("middle index required in 3-index slice")
}
if index[2] == nil {
Yyerror("final index required in 3-index slice")
yyerror("final index required in 3-index slice")
}
x = Nod(OSLICE3, x, nil)
x.SetSliceBounds(index[0], index[1], index[2])
......@@ -1581,7 +1581,7 @@ func (p *parser) dotdotdot() *Node {
return Nod(ODDD, typ, nil)
}
Yyerror("final argument in variadic function missing type")
yyerror("final argument in variadic function missing type")
return Nod(ODDD, typenod(typ(TINTER)), nil)
}
......@@ -1737,7 +1737,7 @@ func (p *parser) new_dotname(obj *Node) *Node {
obj.Used = true
return oldname(s)
}
return NodSym(OXDOT, obj, sel)
return nodSym(OXDOT, obj, sel)
}
func (p *parser) dotname() *Node {
......@@ -1815,7 +1815,7 @@ func (p *parser) xfndcl() *Node {
f.Nbody.Set(body)
f.Noescape = p.pragma&Noescape != 0
if f.Noescape && len(body) != 0 {
Yyerror("can only use //go:noescape with external func implementations")
yyerror("can only use //go:noescape with external func implementations")
}
f.Func.Pragma = p.pragma
f.Func.Endlineno = lineno
......@@ -1844,13 +1844,13 @@ func (p *parser) fndcl() *Node {
if name.Name == "init" {
name = renameinit()
if t.List.Len() > 0 || t.Rlist.Len() > 0 {
Yyerror("func init must have no arguments and no return values")
yyerror("func init must have no arguments and no return values")
}
}
if localpkg.Name == "main" && name.Name == "main" {
if t.List.Len() > 0 || t.Rlist.Len() > 0 {
Yyerror("func main must have no arguments and no return values")
yyerror("func main must have no arguments and no return values")
}
}
......@@ -1875,17 +1875,17 @@ func (p *parser) fndcl() *Node {
// check after parsing header for fault-tolerance
if recv == nil {
Yyerror("method has no receiver")
yyerror("method has no receiver")
return nil
}
if len(rparam) > 1 {
Yyerror("method has multiple receivers")
yyerror("method has multiple receivers")
return nil
}
if recv.Op != ODCLFIELD {
Yyerror("bad receiver in method")
yyerror("bad receiver in method")
return nil
}
......@@ -2026,7 +2026,7 @@ func (p *parser) structdcl() []*Node {
field.Right = Nod(OIND, field.Right, nil)
field.SetVal(tag)
Yyerror("cannot parenthesize embedded type")
yyerror("cannot parenthesize embedded type")
return []*Node{field}
} else {
......@@ -2036,7 +2036,7 @@ func (p *parser) structdcl() []*Node {
tag := p.oliteral()
field.SetVal(tag)
Yyerror("cannot parenthesize embedded type")
yyerror("cannot parenthesize embedded type")
return []*Node{field}
}
......@@ -2050,7 +2050,7 @@ func (p *parser) structdcl() []*Node {
field.Right = Nod(OIND, field.Right, nil)
field.SetVal(tag)
Yyerror("cannot parenthesize embedded type")
yyerror("cannot parenthesize embedded type")
return []*Node{field}
} else {
......@@ -2100,7 +2100,7 @@ func (p *parser) packname(name *Sym) *Sym {
var pkg *Pkg
if name.Def == nil || name.Def.Op != OPACK {
Yyerror("%v is not a package", name)
yyerror("%v is not a package", name)
pkg = localpkg
} else {
name.Def.Used = true
......@@ -2168,7 +2168,7 @@ func (p *parser) interfacedcl() *Node {
pname := p.packname(nil)
p.want(')')
n := Nod(ODCLFIELD, nil, oldname(pname))
Yyerror("cannot parenthesize embedded type")
yyerror("cannot parenthesize embedded type")
return n
default:
......@@ -2287,7 +2287,7 @@ func (p *parser) param_list(dddOk bool) []*Node {
p.typ = T
}
if T == nil {
Yyerror("mixed named and unnamed function parameters")
yyerror("mixed named and unnamed function parameters")
break
}
}
......@@ -2314,9 +2314,9 @@ func (p *parser) param_list(dddOk bool) []*Node {
// rewrite ...T parameter
if typ != nil && typ.Op == ODDD {
if !dddOk {
Yyerror("cannot use ... in receiver or result parameter list")
yyerror("cannot use ... in receiver or result parameter list")
} else if i+1 < len(params) {
Yyerror("can only use ... with final parameter in list")
yyerror("can only use ... with final parameter in list")
}
typ.Op = OTARRAY
typ.Right = typ.Left
......@@ -2418,7 +2418,7 @@ func (p *parser) stmt() *Node {
break
}
if ln.Sym.Def != ln {
Yyerror("%s is shadowed during return", ln.Sym.Name)
yyerror("%s is shadowed during return", ln.Sym.Name)
}
}
}
......
......@@ -19,7 +19,7 @@ var makefuncdatasym_nsym int
func makefuncdatasym(nameprefix string, funcdatakind int64) *Sym {
var nod Node
sym := LookupN(nameprefix, makefuncdatasym_nsym)
sym := lookupN(nameprefix, makefuncdatasym_nsym)
makefuncdatasym_nsym++
pnod := newname(sym)
pnod.Class = PEXTERN
......@@ -89,7 +89,7 @@ func gvardefx(n *Node, as obj.As) {
Fatalf("gvardef nil")
}
if n.Op != ONAME {
Yyerror("gvardef %#v; %v", n.Op, n)
yyerror("gvardef %#v; %v", n.Op, n)
return
}
......@@ -132,7 +132,7 @@ func emitptrargsmap() {
if Curfn.Func.Nname.Sym.Name == "_" {
return
}
sym := Lookup(fmt.Sprintf("%s.args_stackmap", Curfn.Func.Nname.Sym.Name))
sym := lookup(fmt.Sprintf("%s.args_stackmap", Curfn.Func.Nname.Sym.Name))
nptr := int(Curfn.Type.ArgWidth() / int64(Widthptr))
bv := bvalloc(int32(nptr) * 2)
......@@ -281,7 +281,7 @@ func allocauto(ptxt *obj.Prog) {
}
if Stksize >= 1<<31 {
setlineno(Curfn)
Yyerror("stack frame too large (>2GB)")
yyerror("stack frame too large (>2GB)")
}
stkdelta[n] = -Stksize - n.Xoffset
......@@ -325,7 +325,7 @@ func compile(fn *Node) {
if fn.Nbody.Len() == 0 {
if pure_go || strings.HasPrefix(fn.Func.Nname.Sym.Name, "init.") {
Yyerror("missing function body for %q", fn.Func.Nname.Sym.Name)
yyerror("missing function body for %q", fn.Func.Nname.Sym.Name)
return
}
......
......@@ -806,7 +806,7 @@ func checkauto(fn *Node, p *obj.Prog, n *Node) {
for _, ln := range fn.Func.Dcl {
fmt.Printf("\t%v (%p; class=%d)\n", ln, ln, ln.Class)
}
Yyerror("checkauto: invariant lost")
yyerror("checkauto: invariant lost")
}
func checkparam(fn *Node, p *obj.Prog, n *Node) {
......@@ -823,7 +823,7 @@ func checkparam(fn *Node, p *obj.Prog, n *Node) {
for _, ln := range fn.Func.Dcl {
fmt.Printf("\t%v (%p; class=%d)\n", ln, ln, ln.Class)
}
Yyerror("checkparam: invariant lost")
yyerror("checkparam: invariant lost")
}
func checkprog(fn *Node, p *obj.Prog) {
......@@ -1423,7 +1423,7 @@ func livenessepilogue(lv *Liveness) {
}
}
Flusherrors()
flusherrors()
}
// FNV-1 hash function constants.
......
......@@ -230,7 +230,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
instrumentnode(&n.Left, init, 0, 0)
if n.Left.Type.IsMap() {
n1 := Nod(OCONVNOP, n.Left, nil)
n1.Type = Ptrto(Types[TUINT8])
n1.Type = ptrto(Types[TUINT8])
n1 = Nod(OIND, n1, nil)
n1 = typecheck(n1, Erv)
callinstr(&n1, init, 0, skip)
......@@ -375,17 +375,17 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
OAS2RECV,
OAS2MAPR,
OASOP:
Yyerror("instrument: %v must be lowered by now", n.Op)
yyerror("instrument: %v must be lowered by now", n.Op)
goto ret
// impossible nodes: only appear in backend.
case ORROTC, OEXTEND:
Yyerror("instrument: %v cannot exist now", n.Op)
yyerror("instrument: %v cannot exist now", n.Op)
goto ret
case OGETG:
Yyerror("instrument: OGETG can happen only in runtime which we don't instrument")
yyerror("instrument: OGETG can happen only in runtime which we don't instrument")
goto ret
case OFOR:
......@@ -587,7 +587,7 @@ func uintptraddr(n *Node) *Node {
func detachexpr(n *Node, init *Nodes) *Node {
addr := Nod(OADDR, n, nil)
l := temp(Ptrto(n.Type))
l := temp(ptrto(n.Type))
as := Nod(OAS, l, addr)
as = typecheck(as, Etop)
as = walkexpr(as, init)
......
......@@ -48,7 +48,7 @@ func typecheckrange(n *Node) {
toomany = 0
switch t.Etype {
default:
Yyerror("cannot range over %L", n.Right)
yyerror("cannot range over %L", n.Right)
goto out
case TARRAY, TSLICE:
......@@ -61,7 +61,7 @@ func typecheckrange(n *Node) {
case TCHAN:
if !t.ChanDir().CanRecv() {
Yyerror("invalid operation: range %v (receive from send-only type %v)", n.Right, n.Right.Type)
yyerror("invalid operation: range %v (receive from send-only type %v)", n.Right, n.Right.Type)
goto out
}
......@@ -77,7 +77,7 @@ func typecheckrange(n *Node) {
}
if n.List.Len() > 2 || toomany != 0 {
Yyerror("too many variables in range")
yyerror("too many variables in range")
}
v1 = nil
......@@ -104,7 +104,7 @@ func typecheckrange(n *Node) {
if v1.Name != nil && v1.Name.Defn == n {
v1.Type = t1
} else if v1.Type != nil && assignop(t1, v1.Type, &why) == 0 {
Yyerror("cannot assign type %v to %L in range%s", t1, v1, why)
yyerror("cannot assign type %v to %L in range%s", t1, v1, why)
}
checkassign(n, v1)
}
......@@ -113,7 +113,7 @@ func typecheckrange(n *Node) {
if v2.Name != nil && v2.Name.Defn == n {
v2.Type = t2
} else if v2.Type != nil && assignop(t2, v2.Type, &why) == 0 {
Yyerror("cannot assign type %v to %L in range%s", t2, v2, why)
yyerror("cannot assign type %v to %L in range%s", t2, v2, why)
}
checkassign(n, v2)
}
......@@ -182,7 +182,7 @@ func walkrange(n *Node) {
init = append(init, Nod(OAS, hv1, nil))
init = append(init, Nod(OAS, hn, Nod(OLEN, ha, nil)))
if v2 != nil {
hp = temp(Ptrto(n.Type.Elem()))
hp = temp(ptrto(n.Type.Elem()))
tmp := Nod(OINDEX, ha, nodintconst(0))
tmp.Bounded = true
init = append(init, Nod(OAS, hp, Nod(OADDR, tmp, nil)))
......@@ -235,20 +235,20 @@ func walkrange(n *Node) {
fn = substArgTypes(fn, t.Key(), t.Val(), th)
init = append(init, mkcall1(fn, nil, nil, typename(t), ha, Nod(OADDR, hit, nil)))
n.Left = Nod(ONE, NodSym(ODOT, hit, keysym), nodnil())
n.Left = Nod(ONE, nodSym(ODOT, hit, keysym), nodnil())
fn = syslook("mapiternext")
fn = substArgTypes(fn, th)
n.Right = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil))
key := NodSym(ODOT, hit, keysym)
key := nodSym(ODOT, hit, keysym)
key = Nod(OIND, key, nil)
if v1 == nil {
body = nil
} else if v2 == nil {
body = []*Node{Nod(OAS, v1, key)}
} else {
val := NodSym(ODOT, hit, valsym)
val := nodSym(ODOT, hit, valsym)
val = Nod(OIND, val, nil)
a := Nod(OAS2, nil, nil)
a.List.Set([]*Node{v1, v2})
......@@ -269,7 +269,7 @@ func walkrange(n *Node) {
}
hb := temp(Types[TBOOL])
n.Left = Nod(ONE, hb, Nodbool(false))
n.Left = Nod(ONE, hb, nodbool(false))
a := Nod(OAS2RECV, nil, nil)
a.Typecheck = 1
a.List.Set([]*Node{hv1, hb})
......@@ -406,13 +406,13 @@ func memclrrange(n, v1, v2, a *Node) bool {
n.Left = Nod(ONE, Nod(OLEN, a, nil), nodintconst(0))
// hp = &a[0]
hp := temp(Ptrto(Types[TUINT8]))
hp := temp(ptrto(Types[TUINT8]))
tmp := Nod(OINDEX, a, nodintconst(0))
tmp.Bounded = true
tmp = Nod(OADDR, tmp, nil)
tmp = Nod(OCONVNOP, tmp, nil)
tmp.Type = Ptrto(Types[TUINT8])
tmp.Type = ptrto(Types[TUINT8])
n.Nbody.Append(Nod(OAS, hp, tmp))
// hn = len(a) * sizeof(elem(a))
......
......@@ -102,10 +102,10 @@ func mapbucket(t *Type) *Type {
dowidth(keytype)
dowidth(valtype)
if keytype.Width > MAXKEYSIZE {
keytype = Ptrto(keytype)
keytype = ptrto(keytype)
}
if valtype.Width > MAXVALSIZE {
valtype = Ptrto(valtype)
valtype = ptrto(valtype)
}
field := make([]*Field, 0, 5)
......@@ -149,7 +149,7 @@ func mapbucket(t *Type) *Type {
// Arrange for the bucket to have no pointers by changing
// the type of the overflow field to uintptr in this case.
// See comment on hmap.overflow in ../../../../runtime/hashmap.go.
otyp := Ptrto(bucket)
otyp := ptrto(bucket)
if !haspointers(t.Val()) && !haspointers(t.Key()) && t.Val().Width <= MAXVALSIZE && t.Key().Width <= MAXKEYSIZE {
otyp = Types[TUINTPTR]
}
......@@ -165,7 +165,7 @@ func mapbucket(t *Type) *Type {
// Double-check that overflow field is final memory in struct,
// with no padding at end. See comment above.
if ovf.Offset != bucket.Width-int64(Widthptr) {
Yyerror("bad math in mapbucket for %v", t)
yyerror("bad math in mapbucket for %v", t)
}
t.MapType().Bucket = bucket
......@@ -188,8 +188,8 @@ func hmap(t *Type) *Type {
makefield("B", Types[TUINT8]),
makefield("noverflow", Types[TUINT16]),
makefield("hash0", Types[TUINT32]),
makefield("buckets", Ptrto(bucket)),
makefield("oldbuckets", Ptrto(bucket)),
makefield("buckets", ptrto(bucket)),
makefield("oldbuckets", ptrto(bucket)),
makefield("nevacuate", Types[TUINTPTR]),
makefield("overflow", Types[TUNSAFEPTR]),
}
......@@ -226,12 +226,12 @@ func hiter(t *Type) *Type {
// }
// must match ../../../../runtime/hashmap.go:hiter.
var field [12]*Field
field[0] = makefield("key", Ptrto(t.Key()))
field[1] = makefield("val", Ptrto(t.Val()))
field[2] = makefield("t", Ptrto(Types[TUINT8]))
field[3] = makefield("h", Ptrto(hmap(t)))
field[4] = makefield("buckets", Ptrto(mapbucket(t)))
field[5] = makefield("bptr", Ptrto(mapbucket(t)))
field[0] = makefield("key", ptrto(t.Key()))
field[1] = makefield("val", ptrto(t.Val()))
field[2] = makefield("t", ptrto(Types[TUINT8]))
field[3] = makefield("h", ptrto(hmap(t)))
field[4] = makefield("buckets", ptrto(mapbucket(t)))
field[5] = makefield("bptr", ptrto(mapbucket(t)))
field[6] = makefield("overflow0", Types[TUNSAFEPTR])
field[7] = makefield("overflow1", Types[TUNSAFEPTR])
field[8] = makefield("startBucket", Types[TUINTPTR])
......@@ -245,7 +245,7 @@ func hiter(t *Type) *Type {
i.SetFields(field[:])
dowidth(i)
if i.Width != int64(12*Widthptr) {
Yyerror("hash_iter size not correct %d %d", i.Width, 12*Widthptr)
yyerror("hash_iter size not correct %d %d", i.Width, 12*Widthptr)
}
t.MapType().Hiter = i
i.StructType().Map = t
......@@ -301,7 +301,7 @@ func methods(t *Type) []*Sig {
it := t
if !isdirectiface(it) {
it = Ptrto(t)
it = ptrto(t)
}
// make list of methods for t,
......@@ -830,7 +830,7 @@ func dcommontype(s *Sym, ot int, t *Type) int {
}
var sptr *Sym
tptr := Ptrto(t)
tptr := ptrto(t)
if !t.IsPtr() && (t.Sym != nil || methods(tptr) != nil) {
sptr = dtypesym(tptr)
}
......@@ -972,7 +972,7 @@ func typenamesym(t *Type) *Sym {
func typename(t *Type) *Node {
s := typenamesym(t)
n := Nod(OADDR, s.Def, nil)
n.Type = Ptrto(s.Def.Type)
n.Type = ptrto(s.Def.Type)
n.Addable = true
n.Ullman = 2
n.Typecheck = 1
......@@ -995,7 +995,7 @@ func itabname(t, itype *Type) *Node {
}
n := Nod(OADDR, s.Def, nil)
n.Type = Ptrto(s.Def.Type)
n.Type = ptrto(s.Def.Type)
n.Addable = true
n.Ullman = 2
n.Typecheck = 1
......@@ -1385,7 +1385,7 @@ func dumptypestructs() {
t := n.Type
dtypesym(t)
if t.Sym != nil {
dtypesym(Ptrto(t))
dtypesym(ptrto(t))
}
}
......@@ -1458,14 +1458,14 @@ func dumptypestructs() {
// but using runtime means fewer copies in .6 files.
if myimportpath == "runtime" {
for i := EType(1); i <= TBOOL; i++ {
dtypesym(Ptrto(Types[i]))
dtypesym(ptrto(Types[i]))
}
dtypesym(Ptrto(Types[TSTRING]))
dtypesym(Ptrto(Types[TUNSAFEPTR]))
dtypesym(ptrto(Types[TSTRING]))
dtypesym(ptrto(Types[TUNSAFEPTR]))
// emit type structs for error and func(error) string.
// The latter is the type of an auto-generated wrapper.
dtypesym(Ptrto(errortype))
dtypesym(ptrto(errortype))
dtypesym(functype(nil, []*Node{Nod(ODCLFIELD, nil, typenod(errortype))}, []*Node{Nod(ODCLFIELD, nil, typenod(Types[TSTRING]))}))
......@@ -1770,7 +1770,7 @@ func zeroaddr(size int64) *Node {
s.Def = x
}
z := Nod(OADDR, s.Def, nil)
z.Type = Ptrto(Types[TUINT8])
z.Type = ptrto(Types[TUINT8])
z.Addable = true
z.Typecheck = 1
return z
......
......@@ -24,12 +24,12 @@ func typecheckselect(sel *Node) {
if ncase.List.Len() == 0 {
// default
if def != nil {
Yyerror("multiple defaults in select (first at %v)", def.Line())
yyerror("multiple defaults in select (first at %v)", def.Line())
} else {
def = ncase
}
} else if ncase.List.Len() > 1 {
Yyerror("select cases cannot be lists")
yyerror("select cases cannot be lists")
} else {
ncase.List.SetIndex(0, typecheck(ncase.List.Index(0), Etop))
n = ncase.List.Index(0)
......@@ -38,7 +38,7 @@ func typecheckselect(sel *Node) {
setlineno(n)
switch n.Op {
default:
Yyerror("select case must be receive, send or assign recv")
yyerror("select case must be receive, send or assign recv")
// convert x = <-c into OSELRECV(x, <-c).
// remove implicit conversions; the eventual assignment
......@@ -49,7 +49,7 @@ func typecheckselect(sel *Node) {
}
if n.Right.Op != ORECV {
Yyerror("select assignment must have receive on right hand side")
yyerror("select assignment must have receive on right hand side")
break
}
......@@ -58,7 +58,7 @@ func typecheckselect(sel *Node) {
// convert x, ok = <-c into OSELRECV2(x, <-c) with ntest=ok
case OAS2RECV:
if n.Rlist.First().Op != ORECV {
Yyerror("select assignment must have receive on right hand side")
yyerror("select assignment must have receive on right hand side")
break
}
......@@ -260,7 +260,7 @@ func walkselect(sel *Node) {
r = Nod(OAS, selv, nil)
r = typecheck(r, Etop)
init = append(init, r)
var_ = conv(conv(Nod(OADDR, selv, nil), Types[TUNSAFEPTR]), Ptrto(Types[TUINT8]))
var_ = conv(conv(Nod(OADDR, selv, nil), Types[TUNSAFEPTR]), ptrto(Types[TUINT8]))
r = mkcall("newselect", nil, nil, var_, nodintconst(selv.Type.Width), nodintconst(sel.Xoffset))
r = typecheck(r, Etop)
init = append(init, r)
......@@ -324,28 +324,28 @@ func selecttype(size int32) *Type {
// and then cache; and also cache Select per size.
scase := Nod(OTSTRUCT, nil, nil)
scase.List.Append(Nod(ODCLFIELD, newname(Lookup("elem")), typenod(Ptrto(Types[TUINT8]))))
scase.List.Append(Nod(ODCLFIELD, newname(Lookup("chan")), typenod(Ptrto(Types[TUINT8]))))
scase.List.Append(Nod(ODCLFIELD, newname(Lookup("pc")), typenod(Types[TUINTPTR])))
scase.List.Append(Nod(ODCLFIELD, newname(Lookup("kind")), typenod(Types[TUINT16])))
scase.List.Append(Nod(ODCLFIELD, newname(Lookup("so")), typenod(Types[TUINT16])))
scase.List.Append(Nod(ODCLFIELD, newname(Lookup("receivedp")), typenod(Ptrto(Types[TUINT8]))))
scase.List.Append(Nod(ODCLFIELD, newname(Lookup("releasetime")), typenod(Types[TUINT64])))
scase.List.Append(Nod(ODCLFIELD, newname(lookup("elem")), typenod(ptrto(Types[TUINT8]))))
scase.List.Append(Nod(ODCLFIELD, newname(lookup("chan")), typenod(ptrto(Types[TUINT8]))))
scase.List.Append(Nod(ODCLFIELD, newname(lookup("pc")), typenod(Types[TUINTPTR])))
scase.List.Append(Nod(ODCLFIELD, newname(lookup("kind")), typenod(Types[TUINT16])))
scase.List.Append(Nod(ODCLFIELD, newname(lookup("so")), typenod(Types[TUINT16])))
scase.List.Append(Nod(ODCLFIELD, newname(lookup("receivedp")), typenod(ptrto(Types[TUINT8]))))
scase.List.Append(Nod(ODCLFIELD, newname(lookup("releasetime")), typenod(Types[TUINT64])))
scase = typecheck(scase, Etype)
scase.Type.Noalg = true
scase.Type.Local = true
sel := Nod(OTSTRUCT, nil, nil)
sel.List.Append(Nod(ODCLFIELD, newname(Lookup("tcase")), typenod(Types[TUINT16])))
sel.List.Append(Nod(ODCLFIELD, newname(Lookup("ncase")), typenod(Types[TUINT16])))
sel.List.Append(Nod(ODCLFIELD, newname(Lookup("pollorder")), typenod(Ptrto(Types[TUINT8]))))
sel.List.Append(Nod(ODCLFIELD, newname(Lookup("lockorder")), typenod(Ptrto(Types[TUINT8]))))
sel.List.Append(Nod(ODCLFIELD, newname(lookup("tcase")), typenod(Types[TUINT16])))
sel.List.Append(Nod(ODCLFIELD, newname(lookup("ncase")), typenod(Types[TUINT16])))
sel.List.Append(Nod(ODCLFIELD, newname(lookup("pollorder")), typenod(ptrto(Types[TUINT8]))))
sel.List.Append(Nod(ODCLFIELD, newname(lookup("lockorder")), typenod(ptrto(Types[TUINT8]))))
arr := Nod(OTARRAY, nodintconst(int64(size)), scase)
sel.List.Append(Nod(ODCLFIELD, newname(Lookup("scase")), arr))
sel.List.Append(Nod(ODCLFIELD, newname(lookup("scase")), arr))
arr = Nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16]))
sel.List.Append(Nod(ODCLFIELD, newname(Lookup("lockorderarr")), arr))
sel.List.Append(Nod(ODCLFIELD, newname(lookup("lockorderarr")), arr))
arr = Nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16]))
sel.List.Append(Nod(ODCLFIELD, newname(Lookup("pollorderarr")), arr))
sel.List.Append(Nod(ODCLFIELD, newname(lookup("pollorderarr")), arr))
sel = typecheck(sel, Etype)
sel.Type.Noalg = true
sel.Type.Local = true
......
......@@ -162,7 +162,7 @@ func foundinitloop(node, visited *Node) {
// those errors probably confused us and
// there might not be a loop. Let the user
// fix those first.
Flusherrors()
flusherrors()
if nerrors > 0 {
errorexit()
}
......@@ -533,7 +533,7 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
*out = append(*out, Nod(OAS, a, val))
}
ptr := Nod(OADDR, a, nil)
n.Type = Ptrto(val.Type)
n.Type = ptrto(val.Type)
gdata(&n, ptr, Widthptr)
}
......@@ -571,7 +571,7 @@ const (
// Callers should set n.Name.Readonly = true on the
// returned node for readonly nodes.
func staticname(t *Type) *Node {
n := newname(LookupN("statictmp_", statuniqgen))
n := newname(lookupN("statictmp_", statuniqgen))
statuniqgen++
addvar(n, t, PEXTERN)
return n
......@@ -694,7 +694,7 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes)
case OARRAYLIT, OSLICELIT:
indexnode = func(index *Node) *Node { return Nod(OINDEX, var_, index) }
case OSTRUCTLIT:
indexnode = func(index *Node) *Node { return NodSym(ODOT, var_, index.Sym) }
indexnode = func(index *Node) *Node { return nodSym(ODOT, var_, index.Sym) }
default:
Fatalf("fixedlit bad op: %v", n.Op)
}
......@@ -805,7 +805,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
}
// make new auto *array (3 declare)
vauto := temp(Ptrto(t))
vauto := temp(ptrto(t))
// set auto to point at new temp or heap (3 assign)
var a *Node
......
This diff is collapsed.
This diff is collapsed.
......@@ -68,7 +68,7 @@ func typecheckswitch(n *Node) {
n.Left.Right = typecheck(n.Left.Right, Erv)
t = n.Left.Right.Type
if t != nil && !t.IsInterface() {
Yyerror("cannot type switch on non-interface value %L", n.Left.Right)
yyerror("cannot type switch on non-interface value %L", n.Left.Right)
}
} else {
// expression switch
......@@ -83,14 +83,14 @@ func typecheckswitch(n *Node) {
if t != nil {
switch {
case !okforeq[t.Etype]:
Yyerror("cannot switch on %L", n.Left)
yyerror("cannot switch on %L", n.Left)
case t.IsSlice():
nilonly = "slice"
case t.IsArray() && !t.IsComparable():
Yyerror("cannot switch on %L", n.Left)
yyerror("cannot switch on %L", n.Left)
case t.IsStruct():
if f := t.IncomparableField(); f != nil {
Yyerror("cannot switch on %L (struct containing %v cannot be compared)", n.Left, f.Type)
yyerror("cannot switch on %L (struct containing %v cannot be compared)", n.Left, f.Type)
}
case t.Etype == TFUNC:
nilonly = "func"
......@@ -109,7 +109,7 @@ func typecheckswitch(n *Node) {
// default
if def != nil {
setlineno(ncase)
Yyerror("multiple defaults in switch (first at %v)", def.Line())
yyerror("multiple defaults in switch (first at %v)", def.Line())
} else {
def = ncase
}
......@@ -130,17 +130,17 @@ func typecheckswitch(n *Node) {
n1 = ls[i1]
switch {
case n1.Op == OTYPE:
Yyerror("type %v is not an expression", n1.Type)
yyerror("type %v is not an expression", n1.Type)
case n1.Type != nil && assignop(n1.Type, t, nil) == 0 && assignop(t, n1.Type, nil) == 0:
if n.Left != nil {
Yyerror("invalid case %v in switch on %v (mismatched types %v and %v)", n1, n.Left, n1.Type, t)
yyerror("invalid case %v in switch on %v (mismatched types %v and %v)", n1, n.Left, n1.Type, t)
} else {
Yyerror("invalid case %v in switch (mismatched types %v and bool)", n1, n1.Type)
yyerror("invalid case %v in switch (mismatched types %v and bool)", n1, n1.Type)
}
case nilonly != "" && !isnil(n1):
Yyerror("invalid case %v in switch (can only compare %s %v to nil)", n1, nilonly, n.Left)
yyerror("invalid case %v in switch (can only compare %s %v to nil)", n1, nilonly, n.Left)
case t.IsInterface() && !n1.Type.IsInterface() && !n1.Type.IsComparable():
Yyerror("invalid case %L in switch (incomparable type)", n1)
yyerror("invalid case %L in switch (incomparable type)", n1)
}
// type switch
......@@ -151,21 +151,21 @@ func typecheckswitch(n *Node) {
case n1.Op == OLITERAL && n1.Type.IsKind(TNIL):
// case nil:
if niltype != nil {
Yyerror("multiple nil cases in type switch (first at %v)", niltype.Line())
yyerror("multiple nil cases in type switch (first at %v)", niltype.Line())
} else {
niltype = ncase
}
case n1.Op != OTYPE && n1.Type != nil: // should this be ||?
Yyerror("%L is not a type", n1)
yyerror("%L is not a type", n1)
// reset to original type
n1 = n.Left.Right
ls[i1] = n1
case !n1.Type.IsInterface() && t.IsInterface() && !implements(n1.Type, t, &missing, &have, &ptr):
if have != nil && !missing.Broke && !have.Broke {
Yyerror("impossible type switch case: %L cannot have dynamic type %v"+
yyerror("impossible type switch case: %L cannot have dynamic type %v"+
" (wrong type for %v method)\n\thave %v%S\n\twant %v%S", n.Left.Right, n1.Type, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else if !missing.Broke {
Yyerror("impossible type switch case: %L cannot have dynamic type %v"+
yyerror("impossible type switch case: %L cannot have dynamic type %v"+
" (missing %v method)", n.Left.Right, n1.Type, missing.Sym)
}
}
......@@ -200,7 +200,7 @@ func typecheckswitch(n *Node) {
func walkswitch(sw *Node) {
// convert switch {...} to switch true {...}
if sw.Left == nil {
sw.Left = Nodbool(true)
sw.Left = nodbool(true)
sw.Left = typecheck(sw.Left, Erv)
}
......@@ -241,7 +241,7 @@ func (s *exprSwitch) walk(sw *Node) {
// convert the switch into OIF statements
var cas []*Node
if s.kind == switchKindTrue || s.kind == switchKindFalse {
s.exprname = Nodbool(s.kind == switchKindTrue)
s.exprname = nodbool(s.kind == switchKindTrue)
} else if consttype(cond) >= 0 {
// leave constants to enable dead code elimination (issue 9608)
s.exprname = cond
......@@ -378,7 +378,7 @@ func casebody(sw *Node, typeswvar *Node) {
case 0:
// default
if def != nil {
Yyerror("more than one default case")
yyerror("more than one default case")
}
// reuse original default case
n.Right = jmp
......@@ -454,12 +454,12 @@ func casebody(sw *Node, typeswvar *Node) {
if last.Xoffset == n.Xoffset && last.Op == OXFALL {
if typeswvar != nil {
setlineno(last)
Yyerror("cannot fallthrough in type switch")
yyerror("cannot fallthrough in type switch")
}
if i+1 >= sw.List.Len() {
setlineno(last)
Yyerror("cannot fallthrough final case in switch")
yyerror("cannot fallthrough final case in switch")
}
last.Op = OFALL
......@@ -609,7 +609,7 @@ func (s *exprSwitch) checkDupCases(cc []caseClause) {
continue
}
setlineno(c.node)
Yyerror("duplicate case %v in switch\n\tprevious case at %v", prev.Left, prev.Line())
yyerror("duplicate case %v in switch\n\tprevious case at %v", prev.Left, prev.Line())
continue
}
if c.node.List.Len() == 2 {
......@@ -623,7 +623,7 @@ func (s *exprSwitch) checkDupCases(cc []caseClause) {
continue
}
setlineno(c.node)
Yyerror("duplicate case %v in switch\n\tprevious case at %v", prev.Left, prev.Line())
yyerror("duplicate case %v in switch\n\tprevious case at %v", prev.Left, prev.Line())
}
continue
}
......@@ -655,7 +655,7 @@ func (s *exprSwitch) checkDupCases(cc []caseClause) {
continue
}
setlineno(c.node)
Yyerror("duplicate case %v in switch\n\tprevious case at %v", prev.Left, prev.Line())
yyerror("duplicate case %v in switch\n\tprevious case at %v", prev.Left, prev.Line())
}
}
......@@ -674,13 +674,13 @@ func (s *typeSwitch) walk(sw *Node) {
}
if cond.Right == nil {
setlineno(sw)
Yyerror("type switch must have an assignment")
yyerror("type switch must have an assignment")
return
}
cond.Right = walkexpr(cond.Right, &sw.Ninit)
if !cond.Right.Type.IsInterface() {
Yyerror("type switch must be on an interface")
yyerror("type switch must be on an interface")
return
}
......@@ -739,7 +739,7 @@ func (s *typeSwitch) walk(sw *Node) {
typ = itabType(typ)
}
// Load hash from type.
h := NodSym(ODOTPTR, typ, nil)
h := nodSym(ODOTPTR, typ, nil)
h.Type = Types[TUINT32]
h.Typecheck = 1
h.Xoffset = int64(2 * Widthptr) // offset of hash in runtime._type
......
......@@ -637,9 +637,9 @@ type Iter struct {
s []*Field
}
// IterFields returns the first field or method in struct or interface type t
// iterFields returns the first field or method in struct or interface type t
// and an Iter value to continue iterating across the rest.
func IterFields(t *Type) (*Field, Iter) {
func iterFields(t *Type) (*Field, Iter) {
return t.Fields().Iter()
}
......@@ -978,8 +978,8 @@ func (t *Type) cmp(x *Type) ssa.Cmp {
fallthrough
case TINTER:
t1, ti := IterFields(t)
x1, xi := IterFields(x)
t1, ti := iterFields(t)
x1, xi := iterFields(x)
for ; t1 != nil && x1 != nil; t1, x1 = ti.Next(), xi.Next() {
if t1.Embedded != x1.Embedded {
return cmpForNe(t1.Embedded < x1.Embedded)
......@@ -1002,8 +1002,8 @@ func (t *Type) cmp(x *Type) ssa.Cmp {
case TFUNC:
for _, f := range recvsParamsResults {
// Loop over fields in structs, ignoring argument names.
ta, ia := IterFields(f(t))
tb, ib := IterFields(f(x))
ta, ia := iterFields(f(t))
tb, ib := iterFields(f(x))
for ; ta != nil && tb != nil; ta, tb = ia.Next(), ib.Next() {
if ta.Isddd != tb.Isddd {
return cmpForNe(!ta.Isddd)
......@@ -1152,7 +1152,7 @@ func (t *Type) ElemType() ssa.Type {
return t.Elem()
}
func (t *Type) PtrTo() ssa.Type {
return Ptrto(t)
return ptrto(t)
}
func (t *Type) NumFields() int {
......
This diff is collapsed.
......@@ -103,18 +103,18 @@ func lexinit() {
idealbool = typ(TBOOL)
s := Pkglookup("true", builtinpkg)
s.Def = Nodbool(true)
s.Def.Sym = Lookup("true")
s.Def = nodbool(true)
s.Def.Sym = lookup("true")
s.Def.Name = new(Name)
s.Def.Type = idealbool
s = Pkglookup("false", builtinpkg)
s.Def = Nodbool(false)
s.Def.Sym = Lookup("false")
s.Def = nodbool(false)
s.Def.Sym = lookup("false")
s.Def.Name = new(Name)
s.Def.Type = idealbool
s = Lookup("_")
s = lookup("_")
s.Block = -100
s.Def = Nod(ONAME, nil, nil)
s.Def.Sym = s
......@@ -361,7 +361,7 @@ func makeErrorInterface() *Type {
rcvr := typ(TSTRUCT)
rcvr.StructType().Funarg = FunargRcvr
field := newField()
field.Type = Ptrto(typ(TSTRUCT))
field.Type = ptrto(typ(TSTRUCT))
rcvr.SetFields([]*Field{field})
in := typ(TSTRUCT)
......@@ -380,7 +380,7 @@ func makeErrorInterface() *Type {
t := typ(TINTER)
field = newField()
field.Sym = Lookup("Error")
field.Sym = lookup("Error")
field.Type = f
t.SetFields([]*Field{field})
......@@ -448,7 +448,7 @@ func finishUniverse() {
if s.Def == nil || (s.Name == "any" && Debug['A'] == 0) {
continue
}
s1 := Lookup(s.Name)
s1 := lookup(s.Name)
if s1.Def != nil {
continue
}
......@@ -461,5 +461,5 @@ func finishUniverse() {
nodfp.Type = Types[TINT32]
nodfp.Xoffset = 0
nodfp.Class = PPARAM
nodfp.Sym = Lookup(".fp")
nodfp.Sym = lookup(".fp")
}
......@@ -21,7 +21,7 @@ func unsafenmagic(nn *Node) *Node {
}
if args.Len() == 0 {
Yyerror("missing argument for %v", s)
yyerror("missing argument for %v", s)
return nil
}
......@@ -60,7 +60,7 @@ func unsafenmagic(nn *Node) *Node {
case ODOT, ODOTPTR:
break
case OCALLPART:
Yyerror("invalid expression %v: argument is a method value", nn)
yyerror("invalid expression %v: argument is a method value", nn)
goto ret
default:
goto bad
......@@ -74,7 +74,7 @@ func unsafenmagic(nn *Node) *Node {
// but accessing f must not otherwise involve
// indirection via embedded pointer types.
if r1.Left != base {
Yyerror("invalid expression %v: selector implies indirection of embedded %v", nn, r1.Left)
yyerror("invalid expression %v: selector implies indirection of embedded %v", nn, r1.Left)
goto ret
}
fallthrough
......@@ -92,12 +92,12 @@ func unsafenmagic(nn *Node) *Node {
}
if args.Len() > 1 {
Yyerror("extra arguments for %v", s)
yyerror("extra arguments for %v", s)
}
goto ret
bad:
Yyerror("invalid expression %v", nn)
yyerror("invalid expression %v", nn)
ret:
// any side effects disappear; ignore init
......
......@@ -16,7 +16,7 @@ func (n *Node) Line() string {
var atExitFuncs []func()
func AtExit(f func()) {
func atExit(f func()) {
atExitFuncs = append(atExitFuncs, f)
}
......@@ -44,7 +44,7 @@ func startProfile() {
if err := pprof.StartCPUProfile(f); err != nil {
Fatalf("%v", err)
}
AtExit(pprof.StopCPUProfile)
atExit(pprof.StopCPUProfile)
}
if memprofile != "" {
if memprofilerate != 0 {
......@@ -54,7 +54,7 @@ func startProfile() {
if err != nil {
Fatalf("%v", err)
}
AtExit(func() {
atExit(func() {
runtime.GC() // profile all outstanding allocations
if err := pprof.WriteHeapProfile(f); err != nil {
Fatalf("%v", err)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment