@@ -1678,8 +1678,19 @@ static int hier2(value *lval)
1678
1678
stgget (& index ,& cidx ); /* mark position in code generator */
1679
1679
ident = expression (& val ,& csetag ,NULL ,TRUE);
1680
1680
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 */
1683
1694
check_tagmismatch (swtag ,csetag ,TRUE,-1 );
1684
1695
/* Search the insertion point (the table is kept in sorted order, so
1685
1696
* that advanced abstract machines can sift the case table with a
@@ -1726,6 +1737,7 @@ static int hier2(value *lval)
1726
1737
} /* if */
1727
1738
sc_allowtags = bck_allowtags ; /* reset */
1728
1739
ident = expression (NULL ,& exprtag ,NULL ,FALSE);
1740
+ skip_default :
1729
1741
if (ident == iARRAY || ident == iREFARRAY )
1730
1742
error (33 ,"-unknown-" ); /* array must be indexed */
1731
1743
if (firstcase ) {
0 commit comments