Commit 0a55958b authored by Luuk van Dijk's avatar Luuk van Dijk

cmd/gc: forgotten recursion on ninit itself in order.c

Fixes test/reorder2.go for all cases tripped up with -lll in 5555072

R=rsc
CC=golang-dev
https://golang.org/cl/5569069
parent fa32b164
...@@ -12,17 +12,14 @@ ...@@ -12,17 +12,14 @@
static void orderstmt(Node*, NodeList**); static void orderstmt(Node*, NodeList**);
static void orderstmtlist(NodeList*, NodeList**); static void orderstmtlist(NodeList*, NodeList**);
static void orderblock(NodeList **l);
static void orderexpr(Node**, NodeList**); static void orderexpr(Node**, NodeList**);
static void orderexprlist(NodeList*, NodeList**); static void orderexprlist(NodeList*, NodeList**);
void void
order(Node *fn) order(Node *fn)
{ {
NodeList *out; orderblock(&fn->nbody);
out = nil;
orderstmtlist(fn->nbody, &out);
fn->nbody = out;
} }
static void static void
...@@ -76,7 +73,7 @@ orderstmtinplace(Node **np) ...@@ -76,7 +73,7 @@ orderstmtinplace(Node **np)
static void static void
orderinit(Node *n, NodeList **out) orderinit(Node *n, NodeList **out)
{ {
*out = concat(*out, n->ninit); orderstmtlist(n->ninit, out);
n->ninit = nil; n->ninit = nil;
} }
...@@ -164,6 +161,9 @@ orderstmt(Node *n, NodeList **out) ...@@ -164,6 +161,9 @@ orderstmt(Node *n, NodeList **out)
return; return;
lno = setlineno(n); lno = setlineno(n);
orderinit(n, out);
switch(n->op) { switch(n->op) {
default: default:
fatal("orderstmt %O", n->op); fatal("orderstmt %O", n->op);
...@@ -182,7 +182,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -182,7 +182,6 @@ orderstmt(Node *n, NodeList **out)
case ORECOVER: case ORECOVER:
case ORECV: case ORECV:
case OSEND: case OSEND:
orderinit(n, out);
orderexpr(&n->left, out); orderexpr(&n->left, out);
orderexpr(&n->right, out); orderexpr(&n->right, out);
orderexprlist(n->list, out); orderexprlist(n->list, out);
...@@ -192,7 +191,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -192,7 +191,6 @@ orderstmt(Node *n, NodeList **out)
case OAS2FUNC: case OAS2FUNC:
// Special: avoid copy of func call n->rlist->n. // Special: avoid copy of func call n->rlist->n.
orderinit(n, out);
orderexprlist(n->list, out); orderexprlist(n->list, out);
ordercall(n->rlist->n, out); ordercall(n->rlist->n, out);
*out = list(*out, n); *out = list(*out, n);
...@@ -200,7 +198,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -200,7 +198,6 @@ orderstmt(Node *n, NodeList **out)
case OAS2RECV: case OAS2RECV:
// Special: avoid copy of receive. // Special: avoid copy of receive.
orderinit(n, out);
orderexprlist(n->list, out); orderexprlist(n->list, out);
orderexpr(&n->rlist->n->left, out); // arg to recv orderexpr(&n->rlist->n->left, out); // arg to recv
*out = list(*out, n); *out = list(*out, n);
...@@ -209,7 +206,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -209,7 +206,6 @@ orderstmt(Node *n, NodeList **out)
case OBLOCK: case OBLOCK:
case OEMPTY: case OEMPTY:
// Special: does not save n onto out. // Special: does not save n onto out.
orderinit(n, out);
orderstmtlist(n->list, out); orderstmtlist(n->list, out);
break; break;
...@@ -223,7 +219,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -223,7 +219,6 @@ orderstmt(Node *n, NodeList **out)
case OGOTO: case OGOTO:
case OLABEL: case OLABEL:
// Special: n->left is not an expression; save as is. // Special: n->left is not an expression; save as is.
orderinit(n, out);
*out = list(*out, n); *out = list(*out, n);
break; break;
...@@ -231,7 +226,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -231,7 +226,6 @@ orderstmt(Node *n, NodeList **out)
case OCALLINTER: case OCALLINTER:
case OCALLMETH: case OCALLMETH:
// Special: handle call arguments. // Special: handle call arguments.
orderinit(n, out);
ordercall(n, out); ordercall(n, out);
*out = list(*out, n); *out = list(*out, n);
break; break;
...@@ -239,13 +233,11 @@ orderstmt(Node *n, NodeList **out) ...@@ -239,13 +233,11 @@ orderstmt(Node *n, NodeList **out)
case ODEFER: case ODEFER:
case OPROC: case OPROC:
// Special: order arguments to inner call but not call itself. // Special: order arguments to inner call but not call itself.
orderinit(n, out);
ordercall(n->left, out); ordercall(n->left, out);
*out = list(*out, n); *out = list(*out, n);
break; break;
case OFOR: case OFOR:
orderinit(n, out);
orderexprinplace(&n->ntest); orderexprinplace(&n->ntest);
orderstmtinplace(&n->nincr); orderstmtinplace(&n->nincr);
orderblock(&n->nbody); orderblock(&n->nbody);
...@@ -253,7 +245,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -253,7 +245,6 @@ orderstmt(Node *n, NodeList **out)
break; break;
case OIF: case OIF:
orderinit(n, out);
orderexprinplace(&n->ntest); orderexprinplace(&n->ntest);
orderblock(&n->nbody); orderblock(&n->nbody);
orderblock(&n->nelse); orderblock(&n->nelse);
...@@ -261,7 +252,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -261,7 +252,6 @@ orderstmt(Node *n, NodeList **out)
break; break;
case ORANGE: case ORANGE:
orderinit(n, out);
orderexpr(&n->right, out); orderexpr(&n->right, out);
for(l=n->list; l; l=l->next) for(l=n->list; l; l=l->next)
orderexprinplace(&l->n); orderexprinplace(&l->n);
...@@ -275,7 +265,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -275,7 +265,6 @@ orderstmt(Node *n, NodeList **out)
break; break;
case OSELECT: case OSELECT:
orderinit(n, out);
for(l=n->list; l; l=l->next) { for(l=n->list; l; l=l->next) {
if(l->n->op != OXCASE) if(l->n->op != OXCASE)
fatal("order select case %O", l->n->op); fatal("order select case %O", l->n->op);
...@@ -299,7 +288,6 @@ orderstmt(Node *n, NodeList **out) ...@@ -299,7 +288,6 @@ orderstmt(Node *n, NodeList **out)
break; break;
case OSWITCH: case OSWITCH:
orderinit(n, out);
orderexpr(&n->ntest, out); orderexpr(&n->ntest, out);
for(l=n->list; l; l=l->next) { for(l=n->list; l; l=l->next) {
if(l->n->op != OXCASE) if(l->n->op != OXCASE)
......
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