Skip to content

Commit 2359f3a

Browse files
skrahGadgetSteve
authored andcommitted
bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. (python#3157)
1 parent 114c71e commit 2359f3a

File tree

13 files changed

+35
-21
lines changed

13 files changed

+35
-21
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3616,7 +3616,7 @@ _build_callargs(PyCFuncPtrObject *self, PyObject *argtypes,
36163616
case (PARAMFLAG_FIN | PARAMFLAG_FOUT):
36173617
*pinoutmask |= (1 << i); /* mark as inout arg */
36183618
(*pnumretvals)++;
3619-
/* fall through to PARAMFLAG_FIN... */
3619+
/* fall through */
36203620
case 0:
36213621
case PARAMFLAG_FIN:
36223622
/* 'in' parameter. Copy it from inargs. */

Objects/call.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg
499499
if (kwargs != NULL && PyDict_GET_SIZE(kwargs) != 0) {
500500
goto no_keyword_error;
501501
}
502-
/* fall through next case */
502+
/* fall through */
503503

504504
case METH_VARARGS | METH_KEYWORDS:
505505
{
@@ -656,7 +656,7 @@ _PyMethodDef_RawFastCallKeywords(PyMethodDef *method, PyObject *self, PyObject *
656656
if (nkwargs) {
657657
goto no_keyword_error;
658658
}
659-
/* fall through next case */
659+
/* fall through */
660660

661661
case METH_VARARGS | METH_KEYWORDS:
662662
{

Objects/stringlib/codecs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
330330
case _Py_ERROR_REPLACE:
331331
memset(p, '?', endpos - startpos);
332332
p += (endpos - startpos);
333-
/* fall through the ignore handler */
333+
/* fall through */
334334
case _Py_ERROR_IGNORE:
335335
i += (endpos - startpos - 1);
336336
break;
@@ -378,7 +378,7 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
378378
}
379379
startpos = k;
380380
assert(startpos < endpos);
381-
/* fall through the default handler */
381+
/* fall through */
382382
default:
383383
rep = unicode_encode_call_errorhandler(
384384
errors, &error_handler_obj, "utf-8", "surrogates not allowed",

Objects/unicodeobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,7 @@ unicode_dealloc(PyObject *unicode)
17941794

17951795
case SSTATE_INTERNED_IMMORTAL:
17961796
Py_FatalError("Immortal interned string died.");
1797+
/* fall through */
17971798

17981799
default:
17991800
Py_FatalError("Inconsistent interned string state.");
@@ -6778,7 +6779,7 @@ unicode_encode_ucs1(PyObject *unicode,
67786779
case _Py_ERROR_REPLACE:
67796780
memset(str, '?', collend - collstart);
67806781
str += (collend - collstart);
6781-
/* fall through ignore error handler */
6782+
/* fall through */
67826783
case _Py_ERROR_IGNORE:
67836784
pos = collend;
67846785
break;
@@ -6817,7 +6818,7 @@ unicode_encode_ucs1(PyObject *unicode,
68176818
break;
68186819
collstart = pos;
68196820
assert(collstart != collend);
6820-
/* fallback to general error handling */
6821+
/* fall through */
68216822

68226823
default:
68236824
rep = unicode_encode_call_errorhandler(errors, &error_handler_obj,

Python/ast.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ ast_for_comp_op(struct compiling *c, const node *n)
11821182
return In;
11831183
if (strcmp(STR(n), "is") == 0)
11841184
return Is;
1185+
/* fall through */
11851186
default:
11861187
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s",
11871188
STR(n));
@@ -1196,6 +1197,7 @@ ast_for_comp_op(struct compiling *c, const node *n)
11961197
return NotIn;
11971198
if (strcmp(STR(CHILD(n, 0)), "is") == 0)
11981199
return IsNot;
1200+
/* fall through */
11991201
default:
12001202
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s",
12011203
STR(CHILD(n, 0)), STR(CHILD(n, 1)));
@@ -3147,6 +3149,7 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
31473149
}
31483150
return Raise(expression, cause, LINENO(n), n->n_col_offset, c->c_arena);
31493151
}
3152+
/* fall through */
31503153
default:
31513154
PyErr_Format(PyExc_SystemError,
31523155
"unexpected flow_stmt: %d", TYPE(ch));

Python/ceval.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,9 +1807,11 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
18071807
switch (oparg) {
18081808
case 2:
18091809
cause = POP(); /* cause */
1810+
/* fall through */
18101811
case 1:
18111812
exc = POP(); /* exc */
1812-
case 0: /* Fallthrough */
1813+
/* fall through */
1814+
case 0:
18131815
if (do_raise(exc, cause)) {
18141816
why = WHY_EXCEPTION;
18151817
goto fast_block_end;

Python/compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,6 +4154,7 @@ expr_constant(struct compiler *c, expr_ty e)
41544154
else if (o == Py_False)
41554155
return 0;
41564156
}
4157+
/* fall through */
41574158
default:
41584159
return -1;
41594160
}
@@ -4446,13 +4447,13 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
44464447
switch (e->v.Attribute.ctx) {
44474448
case AugLoad:
44484449
ADDOP(c, DUP_TOP);
4449-
/* Fall through to load */
4450+
/* Fall through */
44504451
case Load:
44514452
ADDOP_NAME(c, LOAD_ATTR, e->v.Attribute.attr, names);
44524453
break;
44534454
case AugStore:
44544455
ADDOP(c, ROT_TWO);
4455-
/* Fall through to save */
4456+
/* Fall through */
44564457
case Store:
44574458
ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names);
44584459
break;

Python/dtoa.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ _Py_dg_strtod(const char *s00, char **se)
14541454
switch (c) {
14551455
case '-':
14561456
sign = 1;
1457-
/* no break */
1457+
/* fall through */
14581458
case '+':
14591459
c = *++s;
14601460
}
@@ -1523,7 +1523,7 @@ _Py_dg_strtod(const char *s00, char **se)
15231523
switch (c) {
15241524
case '-':
15251525
esign = 1;
1526-
/* no break */
1526+
/* fall through */
15271527
case '+':
15281528
c = *++s;
15291529
}
@@ -2441,15 +2441,15 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
24412441
break;
24422442
case 2:
24432443
leftright = 0;
2444-
/* no break */
2444+
/* fall through */
24452445
case 4:
24462446
if (ndigits <= 0)
24472447
ndigits = 1;
24482448
ilim = ilim1 = i = ndigits;
24492449
break;
24502450
case 3:
24512451
leftright = 0;
2452-
/* no break */
2452+
/* fall through */
24532453
case 5:
24542454
i = ndigits + k + 1;
24552455
ilim = i;

Python/formatter_unicode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
312312
format->thousands_separators = LT_UNDER_FOUR_LOCALE;
313313
break;
314314
}
315+
/* fall through */
315316
default:
316317
invalid_comma_type(format->type);
317318
return 0;

Python/getargs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,8 +2304,8 @@ skipitem(const char **p_format, va_list *p_va, int flags)
23042304
/* after 'e', only 's' and 't' is allowed */
23052305
goto err;
23062306
format++;
2307-
/* explicit fallthrough to string cases */
23082307
}
2308+
/* fall through */
23092309

23102310
case 's': /* string */
23112311
case 'z': /* string or None */

Python/marshal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ r_object(RFILE *p)
11121112

11131113
case TYPE_ASCII_INTERNED:
11141114
is_interned = 1;
1115+
/* fall through */
11151116
case TYPE_ASCII:
11161117
n = r_long(p);
11171118
if (PyErr_Occurred())
@@ -1124,6 +1125,7 @@ r_object(RFILE *p)
11241125

11251126
case TYPE_SHORT_ASCII_INTERNED:
11261127
is_interned = 1;
1128+
/* fall through */
11271129
case TYPE_SHORT_ASCII:
11281130
n = r_byte(p);
11291131
if (n == EOF) {
@@ -1149,6 +1151,7 @@ r_object(RFILE *p)
11491151

11501152
case TYPE_INTERNED:
11511153
is_interned = 1;
1154+
/* fall through */
11521155
case TYPE_UNICODE:
11531156
{
11541157
const char *buffer;

Python/pyhash.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,13 @@ siphash24(const void *src, Py_ssize_t src_sz) {
393393
pt = (uint8_t *)&t;
394394
m = (uint8_t *)in;
395395
switch (src_sz) {
396-
case 7: pt[6] = m[6];
397-
case 6: pt[5] = m[5];
398-
case 5: pt[4] = m[4];
396+
case 7: pt[6] = m[6]; /* fall through */
397+
case 6: pt[5] = m[5]; /* fall through */
398+
case 5: pt[4] = m[4]; /* fall through */
399399
case 4: memcpy(pt, m, sizeof(uint32_t)); break;
400-
case 3: pt[2] = m[2];
401-
case 2: pt[1] = m[1];
402-
case 1: pt[0] = m[0];
400+
case 3: pt[2] = m[2]; /* fall through */
401+
case 2: pt[1] = m[1]; /* fall through */
402+
case 1: pt[0] = m[0]; /* fall through */
403403
}
404404
b |= _le64toh(t);
405405

Python/wordcode_helpers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ write_op_arg(_Py_CODEUNIT *codestr, unsigned char opcode,
2828
switch (ilen) {
2929
case 4:
3030
*codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 24) & 0xff);
31+
/* fall through */
3132
case 3:
3233
*codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 16) & 0xff);
34+
/* fall through */
3335
case 2:
3436
*codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 8) & 0xff);
37+
/* fall through */
3538
case 1:
3639
*codestr++ = PACKOPARG(opcode, oparg & 0xff);
3740
break;

0 commit comments

Comments
 (0)