diff --git a/src/cmd/6g/gen.c b/src/cmd/6g/gen.c index 7c64f4ddce9..ef53696eeea 100644 --- a/src/cmd/6g/gen.c +++ b/src/cmd/6g/gen.c @@ -137,6 +137,9 @@ gen(Node *n, Label *labloop) loop: if(n == N) goto ret; + if(n->ninit) + gen(n->ninit, L); + setlineno(n); switch(n->op) { @@ -234,7 +237,6 @@ loop: break; case OFOR: - gen(n->ninit, L); // init p1 = gbranch(AJMP, T); // goto test sbreak = breakpc; breakpc = gbranch(AJMP, T); // break: goto done @@ -256,7 +258,6 @@ loop: break; case OIF: - gen(n->ninit, L); // init p1 = gbranch(AJMP, T); // goto test p2 = gbranch(AJMP, T); // p2: goto else patch(p1, pc); // test: @@ -269,7 +270,6 @@ loop: break; case OSWITCH: - gen(n->ninit, L); // init p1 = gbranch(AJMP, T); // goto test sbreak = breakpc; breakpc = gbranch(AJMP, T); // break: goto done @@ -284,7 +284,6 @@ loop: break; case OSELECT: - gen(n->ninit, L); sbreak = breakpc; p1 = gbranch(AJMP, T); // goto test breakpc = gbranch(AJMP, T); // break: goto done diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index 56958caff9b..aa3ecf45e18 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -1220,6 +1220,23 @@ isptrdarray(Type *t) return 0; } +int +isselect(Node *n) +{ + Sym *s; + + if(n == N) + return 0; + n = n->left; + s = pkglookup("selectsend", "sys"); + if(s == n->sym) + return 1; + s = pkglookup("selectrecv", "sys"); + if(s == n->sym) + return 1; + return 0; +} + int isinter(Type *t) { diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 3f2e856fd88..3ab4671b8cd 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -21,23 +21,6 @@ walk(Node *fn) dump("fn", fn->nbody); } -int -isselect(Node *n) -{ - Sym *s; - - if(n == N) - return 0; - n = n->left; - s = pkglookup("selectsend", "sys"); - if(s == n->sym) - return 1; - s = pkglookup("selectrecv", "sys"); - if(s == n->sym) - return 1; - return 0; -} - void walktype1(Node *n, int top) { @@ -396,8 +379,6 @@ loop: goto ret; convlit(l, t); - if(l->type == T) - goto ret; // nil conversion if(eqtype(t, l->type, 0)) { @@ -415,6 +396,7 @@ loop: } // to string + if(l->type != T) if(isptrto(t, TSTRING)) { if(isint[l->type->etype]) { *n = *stringop(n, top); @@ -2331,7 +2313,7 @@ walktype(Node *n, int top) r = addtop; addtop = N; walktype1(r, top); - n->ninit = list(r, n->ninit); + n->ninit = list(n->ninit, r); } } @@ -2830,8 +2812,6 @@ structlit(Node *n) if(t->etype != TSTRUCT) fatal("structlit: not struct"); -print("\nstruct lit %lT\n", t); - var = nod(OXXX, N, N); tempname(var, t);