]> Cypherpunks repositories - gostls13.git/commitdiff
bug 152
authorKen Thompson <ken@golang.org>
Wed, 27 May 2009 02:48:39 +0000 (19:48 -0700)
committerKen Thompson <ken@golang.org>
Wed, 27 May 2009 02:48:39 +0000 (19:48 -0700)
R=r
OCL=29419
CL=29419

src/cmd/gc/sinit.c
src/cmd/gc/walk.c

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