From: Ken Thompson Date: Wed, 18 Jun 2008 18:43:50 +0000 (-0700) Subject: bogus diagnostic with X-Git-Tag: weekly.2009-11-06~3660 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1926fef175dc89079f39b952aa02487d5b6e1aeb;p=gostls13.git bogus diagnostic with default as first case in a switch SVN=123398 --- diff --git a/src/cmd/6g/gen.c b/src/cmd/6g/gen.c index b6120d7755..f99114003f 100644 --- a/src/cmd/6g/gen.c +++ b/src/cmd/6g/gen.c @@ -440,7 +440,7 @@ swgen(Node *n) while(c1 != N) { dynlineno = c1->lineno; // for diagnostics if(c1->op != OCASE) { - if(s0 == C) + if(s0 == C && dflt == P) yyerror("unreachable statements in a switch"); gen(c1); @@ -463,7 +463,6 @@ swgen(Node *n) dflt = pc; while(c2 != N) { - s = mal(sizeof(*s)); if(s0 == C) s0 = s; diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 56475b177b..f577a9f708 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -116,6 +116,7 @@ loop: walktype(n->ninit, Etop); walktype(n->ntest, Erv); walktype(n->nbody, Etop); + // find common type if(n->ntest->type == T) n->ntest->type = walkswitch(n, sw1); @@ -127,11 +128,9 @@ loop: // set the type on all literals if(n->ntest->type != T) walkswitch(n, sw3); - - walktype(n->ntest, Erv); - - n = n->nincr; - goto loop; + walktype(n->ntest, Erv); // BOTCH is this right + walktype(n->nincr, Erv); + goto ret; case OEMPTY: if(top != Etop)