1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00

cmd/compile: remove Node.Nincr, Node.Nelse, Node.Initplan

$ sizeof -p cmd/compile/internal/gc Node
Node 288
$

Change-Id: I4e316efa246132b3faa3a892e4fe9c9039250665
Reviewed-on: https://go-review.googlesource.com/10520
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Russ Cox 2015-05-22 01:16:52 -04:00
parent bbdf631f34
commit ffef180f82
16 changed files with 54 additions and 88 deletions

View File

@ -135,9 +135,7 @@ func (v *bottomUpVisitor) visitcode(n *Node, min uint32) uint32 {
min = v.visitcode(n.Right, min) min = v.visitcode(n.Right, min)
min = v.visitcodelist(n.List, min) min = v.visitcodelist(n.List, min)
min = v.visitcode(n.Ntest, min) min = v.visitcode(n.Ntest, min)
min = v.visitcode(n.Nincr, min)
min = v.visitcodelist(n.Nbody, min) min = v.visitcodelist(n.Nbody, min)
min = v.visitcodelist(n.Nelse, min)
min = v.visitcodelist(n.Rlist, min) min = v.visitcodelist(n.Rlist, min)
if n.Op == OCALLFUNC || n.Op == OCALLMETH { if n.Op == OCALLFUNC || n.Op == OCALLMETH {
@ -546,9 +544,7 @@ func escloopdepth(e *EscState, n *Node) {
escloopdepth(e, n.Right) escloopdepth(e, n.Right)
escloopdepthlist(e, n.List) escloopdepthlist(e, n.List)
escloopdepth(e, n.Ntest) escloopdepth(e, n.Ntest)
escloopdepth(e, n.Nincr)
escloopdepthlist(e, n.Nbody) escloopdepthlist(e, n.Nbody)
escloopdepthlist(e, n.Nelse)
escloopdepthlist(e, n.Rlist) escloopdepthlist(e, n.Rlist)
} }
@ -602,9 +598,7 @@ func esc(e *EscState, n *Node, up *Node) {
esc(e, n.Left, n) esc(e, n.Left, n)
esc(e, n.Right, n) esc(e, n.Right, n)
esc(e, n.Ntest, n) esc(e, n.Ntest, n)
esc(e, n.Nincr, n)
esclist(e, n.Nbody, n) esclist(e, n.Nbody, n)
esclist(e, n.Nelse, n)
esclist(e, n.List, n) esclist(e, n.List, n)
esclist(e, n.Rlist, n) esclist(e, n.Rlist, n)

View File

@ -203,9 +203,7 @@ func reexportdep(n *Node) {
reexportdeplist(n.Rlist) reexportdeplist(n.Rlist)
reexportdeplist(n.Ninit) reexportdeplist(n.Ninit)
reexportdep(n.Ntest) reexportdep(n.Ntest)
reexportdep(n.Nincr)
reexportdeplist(n.Nbody) reexportdeplist(n.Nbody)
reexportdeplist(n.Nelse)
} }
func dumpexportconst(s *Sym) { func dumpexportconst(s *Sym) {

View File

@ -867,8 +867,8 @@ func stmtfmt(n *Node) string {
} else { } else {
f += fmt.Sprintf("if %v { %v }", n.Ntest, n.Nbody) f += fmt.Sprintf("if %v { %v }", n.Ntest, n.Nbody)
} }
if n.Nelse != nil { if n.Rlist != nil {
f += fmt.Sprintf(" else { %v }", n.Nelse) f += fmt.Sprintf(" else { %v }", n.Rlist)
} }
case OFOR: case OFOR:
@ -880,7 +880,7 @@ func stmtfmt(n *Node) string {
f += "for" f += "for"
if simpleinit { if simpleinit {
f += fmt.Sprintf(" %v;", n.Ninit.N) f += fmt.Sprintf(" %v;", n.Ninit.N)
} else if n.Nincr != nil { } else if n.Right != nil {
f += " ;" f += " ;"
} }
@ -888,8 +888,8 @@ func stmtfmt(n *Node) string {
f += fmt.Sprintf(" %v", n.Ntest) f += fmt.Sprintf(" %v", n.Ntest)
} }
if n.Nincr != nil { if n.Right != nil {
f += fmt.Sprintf("; %v", n.Nincr) f += fmt.Sprintf("; %v", n.Right)
} else if simpleinit { } else if simpleinit {
f += ";" f += ";"
} }
@ -1571,16 +1571,6 @@ func nodedump(n *Node, flag int) string {
indent(&buf) indent(&buf)
fmt.Fprintf(&buf, "%v-body%v", Oconv(int(n.Op), 0), n.Nbody) fmt.Fprintf(&buf, "%v-body%v", Oconv(int(n.Op), 0), n.Nbody)
} }
if n.Nelse != nil {
indent(&buf)
fmt.Fprintf(&buf, "%v-else%v", Oconv(int(n.Op), 0), n.Nelse)
}
if n.Nincr != nil {
indent(&buf)
fmt.Fprintf(&buf, "%v-incr%v", Oconv(int(n.Op), 0), n.Nincr)
}
} }
return buf.String() return buf.String()

View File

@ -788,7 +788,7 @@ func gen(n *Node) {
lab.Continpc = continpc lab.Continpc = continpc
} }
gen(n.Nincr) // contin: incr gen(n.Right) // contin: incr
Patch(p1, Pc) // test: Patch(p1, Pc) // test:
Bgen(n.Ntest, false, -1, breakpc) // if(!test) goto break Bgen(n.Ntest, false, -1, breakpc) // if(!test) goto break
Genlist(n.Nbody) // body Genlist(n.Nbody) // body
@ -809,7 +809,7 @@ func gen(n *Node) {
Genlist(n.Nbody) // then Genlist(n.Nbody) // then
p3 := gjmp(nil) // goto done p3 := gjmp(nil) // goto done
Patch(p2, Pc) // else: Patch(p2, Pc) // else:
Genlist(n.Nelse) // else Genlist(n.Rlist) // else
Patch(p3, Pc) // done: Patch(p3, Pc) // done:
case OSWITCH: case OSWITCH:

View File

@ -701,7 +701,7 @@ for_header:
$$.Ninit = list1($1); $$.Ninit = list1($1);
} }
$$.Ntest = $3; $$.Ntest = $3;
$$.Nincr = $5; $$.Right = $5;
} }
| osimple_stmt | osimple_stmt
{ {
@ -774,7 +774,7 @@ if_stmt:
if nn.N.Op == OIF { if nn.N.Op == OIF {
popdcl(); popdcl();
} }
n.Nelse = list1(nn.N); n.Rlist = list1(nn.N);
n = nn.N; n = nn.N;
} }
} }

View File

@ -231,7 +231,7 @@ func ishairy(n *Node, budget *int) bool {
(*budget)-- (*budget)--
return *budget < 0 || ishairy(n.Left, budget) || ishairy(n.Right, budget) || ishairylist(n.List, budget) || ishairylist(n.Rlist, budget) || ishairylist(n.Ninit, budget) || ishairy(n.Ntest, budget) || ishairy(n.Nincr, budget) || ishairylist(n.Nbody, budget) || ishairylist(n.Nelse, budget) return *budget < 0 || ishairy(n.Left, budget) || ishairy(n.Right, budget) || ishairylist(n.List, budget) || ishairylist(n.Rlist, budget) || ishairylist(n.Ninit, budget) || ishairy(n.Ntest, budget) || ishairylist(n.Nbody, budget)
} }
// Inlcopy and inlcopylist recursively copy the body of a function. // Inlcopy and inlcopylist recursively copy the body of a function.
@ -266,9 +266,7 @@ func inlcopy(n *Node) *Node {
m.Rlist = inlcopylist(n.Rlist) m.Rlist = inlcopylist(n.Rlist)
m.Ninit = inlcopylist(n.Ninit) m.Ninit = inlcopylist(n.Ninit)
m.Ntest = inlcopy(n.Ntest) m.Ntest = inlcopy(n.Ntest)
m.Nincr = inlcopy(n.Nincr)
m.Nbody = inlcopylist(n.Nbody) m.Nbody = inlcopylist(n.Nbody)
m.Nelse = inlcopylist(n.Nelse)
return m return m
} }
@ -374,8 +372,12 @@ func inlnode(np **Node) {
inlnode(&n.Right) inlnode(&n.Right)
if n.Right != nil && n.Right.Op == OINLCALL { if n.Right != nil && n.Right.Op == OINLCALL {
if n.Op == OFOR {
inlconv2stmt(n.Right)
} else {
inlconv2expr(&n.Right) inlconv2expr(&n.Right)
} }
}
inlnodelist(n.List) inlnodelist(n.List)
switch n.Op { switch n.Op {
@ -423,21 +425,20 @@ func inlnode(np **Node) {
default: default:
for l := n.Rlist; l != nil; l = l.Next { for l := n.Rlist; l != nil; l = l.Next {
if l.N.Op == OINLCALL { if l.N.Op == OINLCALL {
if n.Op == OIF {
inlconv2stmt(l.N)
} else {
inlconv2expr(&l.N) inlconv2expr(&l.N)
} }
} }
} }
}
inlnode(&n.Ntest) inlnode(&n.Ntest)
if n.Ntest != nil && n.Ntest.Op == OINLCALL { if n.Ntest != nil && n.Ntest.Op == OINLCALL {
inlconv2expr(&n.Ntest) inlconv2expr(&n.Ntest)
} }
inlnode(&n.Nincr)
if n.Nincr != nil && n.Nincr.Op == OINLCALL {
inlconv2stmt(n.Nincr)
}
inlnodelist(n.Nbody) inlnodelist(n.Nbody)
for l := n.Nbody; l != nil; l = l.Next { for l := n.Nbody; l != nil; l = l.Next {
if l.N.Op == OINLCALL { if l.N.Op == OINLCALL {
@ -445,13 +446,6 @@ func inlnode(np **Node) {
} }
} }
inlnodelist(n.Nelse)
for l := n.Nelse; l != nil; l = l.Next {
if l.N.Op == OINLCALL {
inlconv2stmt(l.N)
}
}
// with all the branches out of the way, it is now time to // with all the branches out of the way, it is now time to
// transmogrify this node itself unless inhibited by the // transmogrify this node itself unless inhibited by the
// switch at the top of this function. // switch at the top of this function.
@ -972,9 +966,7 @@ func inlsubst(n *Node) *Node {
m.Rlist = inlsubstlist(n.Rlist) m.Rlist = inlsubstlist(n.Rlist)
m.Ninit = concat(m.Ninit, inlsubstlist(n.Ninit)) m.Ninit = concat(m.Ninit, inlsubstlist(n.Ninit))
m.Ntest = inlsubst(n.Ntest) m.Ntest = inlsubst(n.Ntest)
m.Nincr = inlsubst(n.Nincr)
m.Nbody = inlsubstlist(n.Nbody) m.Nbody = inlsubstlist(n.Nbody)
m.Nelse = inlsubstlist(n.Nelse)
return m return m
} }
@ -1002,7 +994,5 @@ func setlno(n *Node, lno int) {
setlnolist(n.Rlist, lno) setlnolist(n.Rlist, lno)
setlnolist(n.Ninit, lno) setlnolist(n.Ninit, lno)
setlno(n.Ntest, lno) setlno(n.Ntest, lno)
setlno(n.Nincr, lno)
setlnolist(n.Nbody, lno) setlnolist(n.Nbody, lno)
setlnolist(n.Nelse, lno)
} }

View File

@ -651,7 +651,7 @@ func orderstmt(n *Node, order *Order) {
cleantempnopop(t, order, &l) cleantempnopop(t, order, &l)
n.Nbody = concat(l, n.Nbody) n.Nbody = concat(l, n.Nbody)
orderblock(&n.Nbody) orderblock(&n.Nbody)
orderstmtinplace(&n.Nincr) orderstmtinplace(&n.Right)
order.out = list(order.out, n) order.out = list(order.out, n)
cleantemp(t, order) cleantemp(t, order)
@ -666,10 +666,10 @@ func orderstmt(n *Node, order *Order) {
n.Nbody = concat(l, n.Nbody) n.Nbody = concat(l, n.Nbody)
l = nil l = nil
cleantempnopop(t, order, &l) cleantempnopop(t, order, &l)
n.Nelse = concat(l, n.Nelse) n.Rlist = concat(l, n.Rlist)
poptemp(t, order) poptemp(t, order)
orderblock(&n.Nbody) orderblock(&n.Nbody)
orderblock(&n.Nelse) orderblock(&n.Rlist)
order.out = list(order.out, n) order.out = list(order.out, n)
// Special: argument will be converted to interface using convT2E // Special: argument will be converted to interface using convT2E

View File

@ -372,8 +372,13 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
goto ret goto ret
// just do generic traversal // just do generic traversal
case OFOR, case OFOR:
OIF, if n.Right != nil {
racewalknode(&n.Right, &n.Right.Ninit, 0, 0)
}
goto ret
case OIF,
OCALLMETH, OCALLMETH,
ORETURN, ORETURN,
ORETJMP, ORETJMP,
@ -413,11 +418,7 @@ ret:
if n.Ntest != nil { if n.Ntest != nil {
racewalknode(&n.Ntest, &n.Ntest.Ninit, 0, 0) racewalknode(&n.Ntest, &n.Ntest.Ninit, 0, 0)
} }
if n.Nincr != nil {
racewalknode(&n.Nincr, &n.Nincr.Ninit, 0, 0)
}
racewalklist(n.Nbody, nil) racewalklist(n.Nbody, nil)
racewalklist(n.Nelse, nil)
racewalklist(n.Rlist, nil) racewalklist(n.Rlist, nil)
*np = n *np = n
} }
@ -577,9 +578,7 @@ func foreach(n *Node, f func(*Node, interface{}), c interface{}) {
foreachnode(n.Right, f, c) foreachnode(n.Right, f, c)
foreachlist(n.List, f, c) foreachlist(n.List, f, c)
foreachnode(n.Ntest, f, c) foreachnode(n.Ntest, f, c)
foreachnode(n.Nincr, f, c)
foreachlist(n.Nbody, f, c) foreachlist(n.Nbody, f, c)
foreachlist(n.Nelse, f, c)
foreachlist(n.Rlist, f, c) foreachlist(n.Rlist, f, c)
} }

View File

@ -146,6 +146,7 @@ func walkrange(n *Node) {
a := n.Right a := n.Right
lno := int(setlineno(a)) lno := int(setlineno(a))
n.Right = nil
var v1 *Node var v1 *Node
if n.List != nil { if n.List != nil {
@ -201,7 +202,6 @@ func walkrange(n *Node) {
n.Nbody = nil n.Nbody = nil
n.Ntest = Nod(ONE, Nod(OLEN, a, nil), Nodintconst(0)) n.Ntest = Nod(ONE, Nod(OLEN, a, nil), Nodintconst(0))
n.Nincr = nil
// hp = &a[0] // hp = &a[0]
hp := temp(Ptrto(Types[TUINT8])) hp := temp(Ptrto(Types[TUINT8]))
@ -267,7 +267,7 @@ func walkrange(n *Node) {
} }
n.Ntest = Nod(OLT, hv1, hn) n.Ntest = Nod(OLT, hv1, hn)
n.Nincr = Nod(OAS, hv1, Nod(OADD, hv1, Nodintconst(1))) n.Right = Nod(OAS, hv1, Nod(OADD, hv1, Nodintconst(1)))
if v1 == nil { if v1 == nil {
body = nil body = nil
} else if v2 == nil { } else if v2 == nil {
@ -294,7 +294,7 @@ func walkrange(n *Node) {
tmp.Right.Typecheck = 1 tmp.Right.Typecheck = 1
a = Nod(OAS, hp, tmp) a = Nod(OAS, hp, tmp)
typecheck(&a, Etop) typecheck(&a, Etop)
n.Nincr.Ninit = list1(a) n.Right.Ninit = list1(a)
} }
// orderstmt allocated the iterator for us. // orderstmt allocated the iterator for us.
@ -317,7 +317,7 @@ func walkrange(n *Node) {
fn = syslook("mapiternext", 1) fn = syslook("mapiternext", 1)
substArgTypes(fn, th) substArgTypes(fn, th)
n.Nincr = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil)) n.Right = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil))
key := Nod(ODOT, hit, keyname) key := Nod(ODOT, hit, keyname)
key = Nod(OIND, key, nil) key = Nod(OIND, key, nil)
@ -397,7 +397,7 @@ func walkrange(n *Node) {
n.Ninit = concat(n.Ninit, init) n.Ninit = concat(n.Ninit, init)
typechecklist(n.Ntest.Ninit, Etop) typechecklist(n.Ntest.Ninit, Etop)
typecheck(&n.Ntest, Erv) typecheck(&n.Ntest, Erv)
typecheck(&n.Nincr, Etop) typecheck(&n.Right, Etop)
typechecklist(body, Etop) typechecklist(body, Etop)
n.Nbody = concat(body, n.Nbody) n.Nbody = concat(body, n.Nbody)
walkstmt(&n) walkstmt(&n)

View File

@ -247,7 +247,7 @@ func walkselect(sel *Node) {
typecheck(&r.Ntest, Erv) typecheck(&r.Ntest, Erv)
r.Nbody = cas.Nbody r.Nbody = cas.Nbody
r.Nelse = concat(dflt.Ninit, dflt.Nbody) r.Rlist = concat(dflt.Ninit, dflt.Nbody)
sel.Nbody = list1(r) sel.Nbody = list1(r)
goto out goto out
} }

View File

@ -19,6 +19,7 @@ const (
) )
var initlist *NodeList var initlist *NodeList
var initplans = make(map[*Node]*InitPlan)
// init1 walks the AST starting at n, and accumulates in out // init1 walks the AST starting at n, and accumulates in out
// the list of definitions needing init code in dependency order. // the list of definitions needing init code in dependency order.
@ -218,7 +219,6 @@ func init2(n *Node, out **NodeList) {
init2list(n.List, out) init2list(n.List, out)
init2list(n.Rlist, out) init2list(n.Rlist, out)
init2list(n.Nbody, out) init2list(n.Nbody, out)
init2list(n.Nelse, out)
if n.Op == OCLOSURE { if n.Op == OCLOSURE {
init2list(n.Param.Closure.Nbody, out) init2list(n.Param.Closure.Nbody, out)
@ -351,7 +351,7 @@ func staticcopy(l *Node, r *Node, out **NodeList) bool {
// fall through // fall through
case OSTRUCTLIT: case OSTRUCTLIT:
p := r.Initplan p := initplans[r]
n1 := *l n1 := *l
var e *InitEntry var e *InitEntry
@ -469,7 +469,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
case OSTRUCTLIT: case OSTRUCTLIT:
initplan(r) initplan(r)
p := r.Initplan p := initplans[r]
n1 = *l n1 = *l
var e *InitEntry var e *InitEntry
var a *Node var a *Node
@ -997,7 +997,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init **NodeList) {
a.Ninit = list1(Nod(OAS, index, Nodintconst(0))) a.Ninit = list1(Nod(OAS, index, Nodintconst(0)))
a.Ntest = Nod(OLT, index, Nodintconst(t.Bound)) a.Ntest = Nod(OLT, index, Nodintconst(t.Bound))
a.Nincr = Nod(OAS, index, Nod(OADD, index, Nodintconst(1))) a.Right = Nod(OAS, index, Nod(OADD, index, Nodintconst(1)))
typecheck(&a, Etop) typecheck(&a, Etop)
walkstmt(&a) walkstmt(&a)
@ -1274,11 +1274,11 @@ func stataddr(nam *Node, n *Node) bool {
} }
func initplan(n *Node) { func initplan(n *Node) {
if n.Initplan != nil { if initplans[n] != nil {
return return
} }
p := new(InitPlan) p := new(InitPlan)
n.Initplan = p initplans[n] = p
switch n.Op { switch n.Op {
default: default:
Fatal("initplan") Fatal("initplan")
@ -1325,7 +1325,7 @@ func addvalue(p *InitPlan, xoffset int64, key *Node, n *Node) {
// special case: inline struct and array (not slice) literals // special case: inline struct and array (not slice) literals
if isvaluelit(n) { if isvaluelit(n) {
initplan(n) initplan(n)
q := n.Initplan q := initplans[n]
var e *InitEntry var e *InitEntry
for i := 0; i < len(q.E); i++ { for i := 0; i < len(q.E); i++ {
e = entry(p) e = entry(p)

View File

@ -326,7 +326,7 @@ func (s *exprSwitch) walkCases(cc []*caseClause) *Node {
} }
typecheck(&a.Ntest, Erv) typecheck(&a.Ntest, Erv)
a.Nbody = list1(s.walkCases(cc[:half])) a.Nbody = list1(s.walkCases(cc[:half]))
a.Nelse = list1(s.walkCases(cc[half:])) a.Rlist = list1(s.walkCases(cc[half:]))
return a return a
} }
@ -688,7 +688,7 @@ func (s *typeSwitch) walkCases(cc []*caseClause) *Node {
a.Ntest = Nod(OLE, s.hashname, Nodintconst(int64(cc[half-1].hash))) a.Ntest = Nod(OLE, s.hashname, Nodintconst(int64(cc[half-1].hash)))
typecheck(&a.Ntest, Erv) typecheck(&a.Ntest, Erv)
a.Nbody = list1(s.walkCases(cc[:half])) a.Nbody = list1(s.walkCases(cc[:half]))
a.Nelse = list1(s.walkCases(cc[half:])) a.Rlist = list1(s.walkCases(cc[half:]))
return a return a
} }

View File

@ -16,10 +16,8 @@ type Node struct {
Left *Node Left *Node
Right *Node Right *Node
Ntest *Node Ntest *Node
Nincr *Node
Ninit *NodeList Ninit *NodeList
Nbody *NodeList Nbody *NodeList
Nelse *NodeList
List *NodeList List *NodeList
Rlist *NodeList Rlist *NodeList
@ -44,7 +42,6 @@ type Node struct {
Pkg *Pkg Pkg *Pkg
// OARRAYLIT, OMAPLIT, OSTRUCTLIT. // OARRAYLIT, OMAPLIT, OSTRUCTLIT.
Initplan *InitPlan
// Escape analysis. // Escape analysis.
Escflowsrc *NodeList // flow(this, src) Escflowsrc *NodeList // flow(this, src)

View File

@ -237,7 +237,7 @@ func callrecv(n *Node) bool {
return true return true
} }
return callrecv(n.Left) || callrecv(n.Right) || callrecv(n.Ntest) || callrecv(n.Nincr) || callrecvlist(n.Ninit) || callrecvlist(n.Nbody) || callrecvlist(n.Nelse) || callrecvlist(n.List) || callrecvlist(n.Rlist) return callrecv(n.Left) || callrecv(n.Right) || callrecv(n.Ntest) || callrecvlist(n.Ninit) || callrecvlist(n.Nbody) || callrecvlist(n.List) || callrecvlist(n.Rlist)
} }
func callrecvlist(l *NodeList) bool { func callrecvlist(l *NodeList) bool {
@ -2104,7 +2104,7 @@ OpSwitch:
Yyerror("non-bool %v used as for condition", Nconv(n.Ntest, obj.FmtLong)) Yyerror("non-bool %v used as for condition", Nconv(n.Ntest, obj.FmtLong))
} }
} }
typecheck(&n.Nincr, Etop) typecheck(&n.Right, Etop)
typechecklist(n.Nbody, Etop) typechecklist(n.Nbody, Etop)
decldepth-- decldepth--
break OpSwitch break OpSwitch
@ -2120,7 +2120,7 @@ OpSwitch:
} }
} }
typechecklist(n.Nbody, Etop) typechecklist(n.Nbody, Etop)
typechecklist(n.Nelse, Etop) typechecklist(n.Rlist, Etop)
break OpSwitch break OpSwitch
case ORETURN: case ORETURN:
@ -3953,10 +3953,8 @@ func markbreak(n *Node, implicit *Node) {
markbreak(n.Right, implicit) markbreak(n.Right, implicit)
markbreak(n.Ntest, implicit) markbreak(n.Ntest, implicit)
markbreak(n.Nincr, implicit)
markbreaklist(n.Ninit, implicit) markbreaklist(n.Ninit, implicit)
markbreaklist(n.Nbody, implicit) markbreaklist(n.Nbody, implicit)
markbreaklist(n.Nelse, implicit)
markbreaklist(n.List, implicit) markbreaklist(n.List, implicit)
markbreaklist(n.Rlist, implicit) markbreaklist(n.Rlist, implicit)
} }
@ -4035,7 +4033,7 @@ func isterminating(l *NodeList, top int) bool {
return true return true
case OIF: case OIF:
return isterminating(n.Nbody, 0) && isterminating(n.Nelse, 0) return isterminating(n.Nbody, 0) && isterminating(n.Rlist, 0)
case OSWITCH, OTYPESW, OSELECT: case OSWITCH, OTYPESW, OSELECT:
if n.Hasbreak { if n.Hasbreak {

View File

@ -255,13 +255,13 @@ func walkstmt(np **Node) {
addinit(&n.Ntest, init) addinit(&n.Ntest, init)
} }
walkstmt(&n.Nincr) walkstmt(&n.Right)
walkstmtlist(n.Nbody) walkstmtlist(n.Nbody)
case OIF: case OIF:
walkexpr(&n.Ntest, &n.Ninit) walkexpr(&n.Ntest, &n.Ninit)
walkstmtlist(n.Nbody) walkstmtlist(n.Nbody)
walkstmtlist(n.Nelse) walkstmtlist(n.Rlist)
case OPROC: case OPROC:
switch n.Left.Op { switch n.Left.Op {
@ -3982,7 +3982,7 @@ func candiscard(n *Node) bool {
return false return false
} }
if !candiscard(n.Left) || !candiscard(n.Right) || !candiscard(n.Ntest) || !candiscard(n.Nincr) || !candiscardlist(n.Ninit) || !candiscardlist(n.Nbody) || !candiscardlist(n.Nelse) || !candiscardlist(n.List) || !candiscardlist(n.Rlist) { if !candiscard(n.Left) || !candiscard(n.Right) || !candiscard(n.Ntest) || !candiscardlist(n.Ninit) || !candiscardlist(n.Nbody) || !candiscardlist(n.List) || !candiscardlist(n.Rlist) {
return false return false
} }

View File

@ -1789,7 +1789,7 @@ yydefault:
yyVAL.node.Ninit = list1(yyDollar[1].node) yyVAL.node.Ninit = list1(yyDollar[1].node)
} }
yyVAL.node.Ntest = yyDollar[3].node yyVAL.node.Ntest = yyDollar[3].node
yyVAL.node.Nincr = yyDollar[5].node yyVAL.node.Right = yyDollar[5].node
} }
case 71: case 71:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
@ -1872,7 +1872,7 @@ yydefault:
if nn.N.Op == OIF { if nn.N.Op == OIF {
popdcl() popdcl()
} }
n.Nelse = list1(nn.N) n.Rlist = list1(nn.N)
n = nn.N n = nn.N
} }
} }