]> Cypherpunks repositories - gostls13.git/commitdiff
bogus diagnostic with
authorKen Thompson <ken@golang.org>
Wed, 18 Jun 2008 18:43:50 +0000 (11:43 -0700)
committerKen Thompson <ken@golang.org>
Wed, 18 Jun 2008 18:43:50 +0000 (11:43 -0700)
default as first case
in a switch

SVN=123398

src/cmd/6g/gen.c
src/cmd/gc/walk.c

index b6120d7755aa8e57fc53ceaa7f0f28bbd1ecb54d..f99114003fbcd4a0cb48698fd10eac345131155c 100644 (file)
@@ -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;
index 56475b177b0bd85113a79c1c28d01d0dbea25832..f577a9f708174dc26cf9d1ea4554d9ab06dc783b 100644 (file)
@@ -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)