Commit a0a14b98 authored by Ken Thompson's avatar Ken Thompson

empty switches -- bug128

R=r
OCL=20520
CL=20522
parent c597845e
...@@ -536,6 +536,8 @@ swgen(Node *n) ...@@ -536,6 +536,8 @@ swgen(Node *n)
c1 = listfirst(&save1, &n->nbody); c1 = listfirst(&save1, &n->nbody);
while(c1 != N) { while(c1 != N) {
setlineno(c1); setlineno(c1);
if(c1->op == OEMPTY)
break;
if(c1->op != OCASE) { if(c1->op != OCASE) {
if(s0 == C && dflt == P) if(s0 == C && dflt == P)
yyerror("unreachable statements in a switch"); yyerror("unreachable statements in a switch");
......
...@@ -277,9 +277,7 @@ loop: ...@@ -277,9 +277,7 @@ loop:
if(top != Etop) if(top != Etop)
goto nottop; goto nottop;
if(!casebody(n->nbody)) casebody(n->nbody);
yyerror("switch statement must have case labels");
if(n->ntest == N) if(n->ntest == N)
n->ntest = booltrue; n->ntest = booltrue;
walkstate(n->ninit); walkstate(n->ninit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment