]> Cypherpunks repositories - gostls13.git/commitdiff
empty switches -- bug128
authorKen Thompson <ken@golang.org>
Fri, 5 Dec 2008 00:05:40 +0000 (16:05 -0800)
committerKen Thompson <ken@golang.org>
Fri, 5 Dec 2008 00:05:40 +0000 (16:05 -0800)
R=r
OCL=20520
CL=20522

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

index 980122b0eb33ee86845a3acbca95acfd7a26ca10..137ad7ae0f5db024cf2f83bcfe7efc51a60d86a4 100644 (file)
@@ -536,6 +536,8 @@ swgen(Node *n)
        c1 = listfirst(&save1, &n->nbody);
        while(c1 != N) {
                setlineno(c1);
+               if(c1->op == OEMPTY)
+                       break;
                if(c1->op != OCASE) {
                        if(s0 == C && dflt == P)
                                yyerror("unreachable statements in a switch");
index 1c87e05eb0fbb3480af68ada76f6e75ddf22a06e..da5917aa7f75dc44695360c87f944c9c6dd65ef4 100644 (file)
@@ -277,9 +277,7 @@ loop:
                if(top != Etop)
                        goto nottop;
 
-               if(!casebody(n->nbody))
-                       yyerror("switch statement must have case labels");
-
+               casebody(n->nbody);
                if(n->ntest == N)
                        n->ntest = booltrue;
                walkstate(n->ninit);