Commit b46e7c4d authored by Ken Thompson's avatar Ken Thompson

bug 152

R=r
OCL=29419
CL=29419
parent 1a0a6f9d
...@@ -264,7 +264,7 @@ initsub(Node *n, Node *nam) ...@@ -264,7 +264,7 @@ initsub(Node *n, Node *nam)
// out of this if we allow minimal simple // out of this if we allow minimal simple
// expression on the right (eg OADDR-ONAME) // expression on the right (eg OADDR-ONAME)
if(n->op != ONAME) if(n->op != ONAME)
return 0; return;
class = typeclass(nam->type); class = typeclass(nam->type);
state = TS_start; state = TS_start;
...@@ -279,7 +279,7 @@ initsub(Node *n, Node *nam) ...@@ -279,7 +279,7 @@ initsub(Node *n, Node *nam)
case TC_map: case TC_map:
goto map; goto map;
} }
return 0; return;
str: str:
for(r=listfirst(&iter, &xxx.list); r != N; r = listnext(&iter)) { for(r=listfirst(&iter, &xxx.list); r != N; r = listnext(&iter)) {
......
...@@ -3580,7 +3580,7 @@ badt: ...@@ -3580,7 +3580,7 @@ badt:
Node* Node*
dorange(Node *nn) dorange(Node *nn)
{ {
Node *k, *v, *m; Node *k, *v, *m, *init;
Node *n, *hv, *hc, *ha, *hk, *ohk, *on, *r, *a; Node *n, *hv, *hc, *ha, *hk, *ohk, *on, *r, *a;
Type *t, *th; Type *t, *th;
int local; int local;
...@@ -3596,6 +3596,7 @@ dorange(Node *nn) ...@@ -3596,6 +3596,7 @@ dorange(Node *nn)
} }
n = nod(OFOR, N, N); n = nod(OFOR, N, N);
init = N;
walktype(nn->right, Erv); walktype(nn->right, Erv);
implicitstar(&nn->right); implicitstar(&nn->right);
...@@ -3624,8 +3625,11 @@ ary: ...@@ -3624,8 +3625,11 @@ ary:
ha = nod(OXXX, N, N); // hidden array ha = nod(OXXX, N, N); // hidden array
tempname(ha, t); tempname(ha, t);
n->ninit = nod(OAS, hk, nodintconst(0)); a = nod(OAS, hk, nodintconst(0));
n->ninit = list(nod(OAS, ha, m), n->ninit); init = list(init, a);
a = nod(OAS, ha, m);
init = list(init, a);
n->ntest = nod(OLT, hk, nod(OLEN, ha, N)); n->ntest = nod(OLT, hk, nod(OLEN, ha, N));
n->nincr = nod(OASOP, hk, nodintconst(1)); n->nincr = nod(OASOP, hk, nodintconst(1));
...@@ -3659,7 +3663,8 @@ map: ...@@ -3659,7 +3663,8 @@ map:
r = nod(OADDR, hk, N); r = nod(OADDR, hk, N);
r = list(m, r); r = list(m, r);
r = nod(OCALL, on, r); r = nod(OCALL, on, r);
n->ninit = r;
init = list(init, r);
r = nod(OINDEX, hk, nodintconst(0)); r = nod(OINDEX, hk, nodintconst(0));
a = nod(OLITERAL, N, N); a = nod(OLITERAL, N, N);
...@@ -3706,10 +3711,13 @@ chan: ...@@ -3706,10 +3711,13 @@ chan:
hv = nod(OXXX, N, N); // hidden value hv = nod(OXXX, N, N); // hidden value
tempname(hv, t->type); tempname(hv, t->type);
n->ninit = list( a = nod(OAS, hc, m);
nod(OAS, hc, m), init = list(init, a);
nod(OAS, hv, nod(ORECV, hc, N))
); a = nod(ORECV, hc, N);
a = nod(OAS, hv, a);
init = list(init, a);
n->ntest = nod(ONOT, nod(OCLOSED, hc, N), N); n->ntest = nod(ONOT, nod(OCLOSED, hc, N), N);
n->nincr = nod(OAS, hv, nod(ORECV, hc, N)); n->nincr = nod(OAS, hv, nod(ORECV, hc, N));
...@@ -3743,11 +3751,11 @@ strng: ...@@ -3743,11 +3751,11 @@ strng:
// ha = s // ha = s
a = nod(OAS, ha, m); a = nod(OAS, ha, m);
n->ninit = a; init = list(init, a);
// ohk = 0 // ohk = 0
a = nod(OAS, ohk, nodintconst(0)); a = nod(OAS, ohk, nodintconst(0));
n->ninit = list(n->ninit, a); init = list(init, a);
// hk[,hv] = stringiter(ha,hk) // hk[,hv] = stringiter(ha,hk)
if(v != N) { if(v != N) {
...@@ -3764,7 +3772,7 @@ strng: ...@@ -3764,7 +3772,7 @@ strng:
a = nod(OCALL, on, a); a = nod(OCALL, on, a);
a = nod(OAS, hk, a); a = nod(OAS, hk, a);
} }
n->ninit = list(n->ninit, a); init = list(init, a);
// while(hk != 0) // while(hk != 0)
n->ntest = nod(ONE, hk, nodintconst(0)); n->ntest = nod(ONE, hk, nodintconst(0));
...@@ -3799,6 +3807,7 @@ strng: ...@@ -3799,6 +3807,7 @@ strng:
goto out; goto out;
out: out:
n->ninit = list(n->ninit, init);
return n; return n;
} }
......
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