Comment fallthrough case statements so compilation succeeds with GCC 7.

GCC 7 Added a warning for implicit fallthroughs in switch cases.
It's enabled by -Wextra, and treated as an error due to -Werror so
compilation fails on GCC 7 and higher.
See -Wimplicit-fallthrough in the GCC manual.
This commit is contained in:
Jack Culhane
2019-05-17 17:00:48 +01:00
parent 9b69648921
commit 1f8269c0e2
6 changed files with 21 additions and 3 deletions

View File

@@ -1021,7 +1021,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel,
return; return;
} }
reread(); reread();
/* fall into default case */ /* fall through */
default: default:
rescantoken(); rescantoken();
@@ -1384,6 +1384,7 @@ creatematrix(void)
switch (gettoken()) { switch (gettoken()) {
case T_RIGHTBRACKET: case T_RIGHTBRACKET:
rescantoken(); rescantoken();
/* fall through */
case T_COMMA: case T_COMMA:
addop(OP_ONE); addop(OP_ONE);
addop(OP_SUB); addop(OP_SUB);
@@ -1394,6 +1395,7 @@ creatematrix(void)
switch(gettoken()) { switch(gettoken()) {
case T_RIGHTBRACKET: case T_RIGHTBRACKET:
rescantoken(); rescantoken();
/* fall through */
case T_COMMA: case T_COMMA:
continue; continue;
} }
@@ -2211,6 +2213,7 @@ getterm(void)
scanerror(T_NULL, scanerror(T_NULL,
"Function calls not allowed " "Function calls not allowed "
"as expressions"); "as expressions");
/* fall through */
default: default:
rescantoken(); rescantoken();
return type; return type;
@@ -2248,7 +2251,7 @@ getidexpr(BOOL okmat, int autodef)
if (autodef != T_GLOBAL && autodef != T_LOCAL && if (autodef != T_GLOBAL && autodef != T_LOCAL &&
autodef != T_STATIC) autodef != T_STATIC)
autodef = 1; autodef = 1;
/* fall into default case */ /* fall through */
default: default:
rescantoken(); rescantoken();
usesymbol(name, autodef); usesymbol(name, autodef);
@@ -2277,6 +2280,7 @@ getidexpr(BOOL okmat, int autodef)
scanerror(T_NULL, scanerror(T_NULL,
"Function calls not allowed " "Function calls not allowed "
"as expressions"); "as expressions");
/* fall through */
default: default:
rescantoken(); rescantoken();
return type; return type;

View File

@@ -909,34 +909,42 @@ setconfig(int type, VALUE *vp)
case CONFIG_PROGRAM: case CONFIG_PROGRAM:
math_error("The program config parameter is read-only"); math_error("The program config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_BASENAME: case CONFIG_BASENAME:
math_error("The basename config parameter is read-only"); math_error("The basename config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_WINDOWS: case CONFIG_WINDOWS:
math_error("The windows config parameter is read-only"); math_error("The windows config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_CYGWIN: case CONFIG_CYGWIN:
math_error("The cygwin config parameter is read-only"); math_error("The cygwin config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_COMPILE_CUSTOM: case CONFIG_COMPILE_CUSTOM:
math_error("The custom config parameter is read-only"); math_error("The custom config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_ALLOW_CUSTOM: case CONFIG_ALLOW_CUSTOM:
math_error("The allow_custom config parameter is read-only"); math_error("The allow_custom config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_VERSION: case CONFIG_VERSION:
math_error("The version config parameter is read-only"); math_error("The version config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_BASEB: case CONFIG_BASEB:
math_error("The baseb config parameter is read-only"); math_error("The baseb config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
case CONFIG_REDECL_WARN: case CONFIG_REDECL_WARN:
if (vp->v_type == V_NUM) { if (vp->v_type == V_NUM) {
@@ -971,10 +979,12 @@ setconfig(int type, VALUE *vp)
case CONFIG_HZ: case CONFIG_HZ:
math_error("The clock tick rate config parameter is read-only"); math_error("The clock tick rate config parameter is read-only");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
default: default:
math_error("Setting illegal config parameter"); math_error("Setting illegal config parameter");
/*NOTREACHED*/ /*NOTREACHED*/
abort();
} }
} }

1
file.c
View File

@@ -1021,6 +1021,7 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
switch (ch) { switch (ch) {
case 's': case 's':
printstring = TRUE; printstring = TRUE;
/* fall through */
case 'c': case 'c':
printchar = TRUE; printchar = TRUE;
case 'd': case 'd':

View File

@@ -4104,8 +4104,9 @@ freenumbers(FUNC *fp)
case OP_QUIT: case OP_QUIT:
freestringconstant( freestringconstant(
(long)fp->f_opcodes[pc]); (long)fp->f_opcodes[pc]);
break;
} }
/*FALLTHRU*/ /* FALLTHRU */
case OPLOC: case OPLOC:
case OPPAR: case OPPAR:
case OPJMP: case OPJMP:

1
qio.c
View File

@@ -144,6 +144,7 @@ qprintf(char *fmt, ...)
case '-': case '-':
sign = -1; sign = -1;
ch = *fmt++; ch = *fmt++;
/* fall through */
default: default:
if (('0' <= ch && ch <= '9') || if (('0' <= ch && ch <= '9') ||
ch == '.' || ch == '*') { ch == '.' || ch == '*') {

View File

@@ -447,6 +447,7 @@ eatstring(int quotechar)
case '\n': case '\n':
if (!newlines) if (!newlines)
break; break;
/* fall through */
case EOF: case EOF:
reread(); reread();
scanerror(T_NULL, scanerror(T_NULL,