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