Skip to content

Commit 77312f5

Browse files
committed
Make the _: part optional
1 parent 8e82958 commit 77312f5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

source/compiler/sc3.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,19 @@ static int hier2(value *lval)
16781678
stgget(&index,&cidx); /* mark position in code generator */
16791679
ident=expression(&val,&csetag,NULL,TRUE);
16801680
stgdel(index,cidx); /* scratch generated code */
1681-
if (ident!=iCONSTEXPR)
1682-
error(8); /* must be constant expression */
1681+
/* if the expression isn't constant, or the next token is ";" or ")",
1682+
* then this must be the default case */
1683+
if (ident!=iCONSTEXPR) {
1684+
implicit_default:
1685+
if (swdefault!=FALSE)
1686+
error(16); /* multiple defaults in switch */
1687+
swdefault=TRUE;
1688+
exprtag=csetag;
1689+
goto skip_default;
1690+
} else if (matchtoken(';') || matchtoken(')')) {
1691+
lexpush();
1692+
goto implicit_default;
1693+
} /* if */
16831694
check_tagmismatch(swtag,csetag,TRUE,-1);
16841695
/* Search the insertion point (the table is kept in sorted order, so
16851696
* that advanced abstract machines can sift the case table with a
@@ -1726,6 +1737,7 @@ static int hier2(value *lval)
17261737
} /* if */
17271738
sc_allowtags=bck_allowtags; /* reset */
17281739
ident=expression(NULL,&exprtag,NULL,FALSE);
1740+
skip_default:
17291741
if (ident==iARRAY || ident==iREFARRAY)
17301742
error(33,"-unknown-"); /* array must be indexed */
17311743
if (firstcase) {

0 commit comments

Comments
 (0)