1
0
mirror of https://github.com/golang/go synced 2024-11-17 09:54:46 -07:00

[dev.regabi] cmd/compile: remove more unused code

Change-Id: I60ac28e3ab376cb0dac23a9b4f481f8562ad8c56
Reviewed-on: https://go-review.googlesource.com/c/go/+/280647
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
Matthew Dempsky 2020-12-29 02:55:05 -08:00
parent 6f30c95048
commit e40cb4d4ae

View File

@ -17,63 +17,6 @@ import (
var DeclContext ir.Class // PEXTERN/PAUTO
func AssignDefn(left []ir.Node, defn ir.Node) {
for _, n := range left {
if n.Sym() != nil {
n.Sym().SetUniq(true)
}
}
var nnew, nerr int
for i, n := range left {
if ir.IsBlank(n) {
continue
}
if !assignableName(n) {
base.ErrorfAt(defn.Pos(), "non-name %v on left side of :=", n)
nerr++
continue
}
if !n.Sym().Uniq() {
base.ErrorfAt(defn.Pos(), "%v repeated on left side of :=", n.Sym())
n.SetDiag(true)
nerr++
continue
}
n.Sym().SetUniq(false)
if n.Sym().Block == types.Block {
continue
}
nnew++
n := NewName(n.Sym())
Declare(n, DeclContext)
n.Defn = defn
defn.PtrInit().Append(ir.NewDecl(base.Pos, ir.ODCL, n))
left[i] = n
}
if nnew == 0 && nerr == 0 {
base.ErrorfAt(defn.Pos(), "no new variables on left side of :=")
}
}
// := declarations
func assignableName(n ir.Node) bool {
switch n.Op() {
case ir.ONAME,
ir.ONONAME,
ir.OPACK,
ir.OTYPE,
ir.OLITERAL:
return n.Sym() != nil
}
return false
}
func DeclFunc(sym *types.Sym, tfn ir.Ntype) *ir.Func {
if tfn.Op() != ir.OTFUNC {
base.Fatalf("expected OTFUNC node, got %v", tfn)