Commit 27a70ea5 authored by Daniel Martí's avatar Daniel Martí

cmd/compile: simplify a few early var declarations

These were likely written in C or added by an automated tool. Either
way, they're unnecessary now. Clean up the code.

Change-Id: I56de2c7bb60ebab8c500803a8b6586bdf4bf75c7
Reviewed-on: https://go-review.googlesource.com/62951
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: default avatarDave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent fa3fe2e3
......@@ -113,15 +113,12 @@ func paramoutheap(fn *Node) bool {
// adds "adjust" to all the argument locations for the call n.
// n must be a defer or go node that has already been walked.
func adjustargs(n *Node, adjust int) {
var arg *Node
var lhs *Node
callfunc := n.Left
for _, arg = range callfunc.List.Slice() {
for _, arg := range callfunc.List.Slice() {
if arg.Op != OAS {
Fatalf("call arg not assignment")
}
lhs = arg.Left
lhs := arg.Left
if lhs.Op == ONAME {
// This is a temporary introduced by reorder1.
// The real store to the stack appears later in the arg list.
......@@ -303,9 +300,8 @@ func walkstmt(n *Node) *Node {
// so that reorder3 can fix up conflicts
var rl []*Node
var cl Class
for _, ln := range Curfn.Func.Dcl {
cl = ln.Class()
cl := ln.Class()
if cl == PAUTO || cl == PAUTOHEAP {
break
}
......@@ -2367,7 +2363,6 @@ func reorder1(all []*Node) []*Node {
var f *Node // last fncall assigned to stack
var r []*Node // non fncalls and tempnames assigned to stack
d := 0
var a *Node
for _, n := range all {
if !n.HasCall() {
r = append(r, n)
......@@ -2381,7 +2376,7 @@ func reorder1(all []*Node) []*Node {
}
// make assignment of fncall to tempname
a = temp(n.Right.Type)
a := temp(n.Right.Type)
a = nod(OAS, a, n.Right)
g = append(g, a)
......@@ -2406,8 +2401,6 @@ func reorder1(all []*Node) []*Node {
//
// function calls have been removed.
func reorder3(all []*Node) []*Node {
var l *Node
// If a needed expression may be affected by an
// earlier assignment, make an early copy of that
// expression and use the copy instead.
......@@ -2415,7 +2408,7 @@ func reorder3(all []*Node) []*Node {
var mapinit Nodes
for i, n := range all {
l = n.Left
l := n.Left
// Save subexpressions needed on left side.
// Drill through non-dereferences.
......@@ -2522,9 +2515,8 @@ func aliased(n *Node, all []*Node, i int) bool {
memwrite := 0
varwrite := 0
var a *Node
for _, an := range all[:i] {
a = outervalue(an.Left)
a := outervalue(an.Left)
for a.Op == ODOT {
a = a.Left
......@@ -3915,12 +3907,10 @@ func walkprintfunc(n *Node, init *Nodes) *Node {
t := nod(OTFUNC, nil, nil)
num := 0
var printargs []*Node
var a *Node
var buf string
for _, n1 := range n.List.Slice() {
buf = fmt.Sprintf("a%d", num)
buf := fmt.Sprintf("a%d", num)
num++
a = namedfield(buf, n1.Type)
a := namedfield(buf, n1.Type)
t.List.Append(a)
printargs = append(printargs, a.Left)
}
......@@ -3932,7 +3922,7 @@ func walkprintfunc(n *Node, init *Nodes) *Node {
sym := lookupN("print·%d", walkprintfunc_prgen)
fn := dclfunc(sym, t)
a = nod(n.Op, nil, nil)
a := nod(n.Op, nil, nil)
a.List.Set(printargs)
a = typecheck(a, Etop)
a = walkstmt(a)
......
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