Skip to content

Commit f38a8e8

Browse files
committed
Add a new error for situations when a switch expression doesn't have a default case
1 parent 87b76af commit f38a8e8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

source/compiler/sc3.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,7 @@ static int hier2(value *lval)
18071807
setlabel(lbl_table);
18081808
assert(swdefault==FALSE || swdefault==TRUE);
18091809
if (swdefault==FALSE) {
1810+
error(95); /* switch expression must contain a "default" case */
18101811
/* store lbl_exit as the "none-matched" label in the switch table */
18111812
strcpy(labelname,itoh(lbl_exit));
18121813
} else {

source/compiler/sc5.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ static char *errmsg[] = {
133133
/*091*/ "ambiguous constant; tag override is required (symbol \"%s\")\n",
134134
/*092*/ "functions may not return arrays of unknown size (symbol \"%s\")\n",
135135
/*093*/ "\"__addressof\" operator is invalid in preprocessor expressions\n",
136-
/*094*/ "division by zero\n"
136+
/*094*/ "division by zero\n",
137+
/*095*/ "switch expression must contain a \"default\" case\n"
137138
};
138139

139140
static char *fatalmsg[] = {

0 commit comments

Comments
 (0)