Skip to content

Commit 1a01a16

Browse files
committed
silence implicit fallthrough gcc warnings
All changes in this patch tries to address implicit fallthrough warnings on the newer gcc compiler. Signed-off-by: Ani Sinha <[email protected]>
1 parent 3c77f38 commit 1a01a16

File tree

9 files changed

+18
-0
lines changed

9 files changed

+18
-0
lines changed

Modules/_ctypes/_ctypes.c

+1
Original file line numberDiff line numberDiff line change
@@ -3704,6 +3704,7 @@ _build_callargs(PyCFuncPtrObject *self, PyObject *argtypes,
37043704
*pinoutmask |= (1 << i); /* mark as inout arg */
37053705
(*pnumretvals)++;
37063706
/* fall through to PARAMFLAG_FIN... */
3707+
__attribute__ ((fallthrough));
37073708
case 0:
37083709
case PARAMFLAG_FIN:
37093710
/* 'in' parameter. Copy it from inargs. */

Modules/zlib/inflate.c

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
#include "inflate.h"
8686
#include "inffast.h"
8787

88+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
89+
8890
#ifdef MAKEFIXED
8991
# ifndef BUILDFIXED
9092
# define BUILDFIXED

Objects/stringobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ string_dealloc(PyObject *op)
590590

591591
case SSTATE_INTERNED_IMMORTAL:
592592
Py_FatalError("Immortal interned string died.");
593+
// fall through
593594

594595
default:
595596
Py_FatalError("Inconsistent interned string state.");

Objects/unicodeobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
796796
#endif
797797
/* fall through... */
798798
}
799+
__attribute__ ((fallthrough));
799800
case '%':
800801
n++;
801802
break;

Python/ast.c

+3
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ ast_for_comp_op(struct compiling *c, const node *n)
549549
return In;
550550
if (strcmp(STR(n), "is") == 0)
551551
return Is;
552+
break;
552553
default:
553554
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s",
554555
STR(n));
@@ -563,6 +564,7 @@ ast_for_comp_op(struct compiling *c, const node *n)
563564
return NotIn;
564565
if (strcmp(STR(CHILD(n, 0)), "is") == 0)
565566
return IsNot;
567+
break;
566568
default:
567569
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s",
568570
STR(CHILD(n, 0)), STR(CHILD(n, 1)));
@@ -2417,6 +2419,7 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
24172419
return Raise(expr1, expr2, expr3, LINENO(n), n->n_col_offset,
24182420
c->c_arena);
24192421
}
2422+
break;
24202423
default:
24212424
PyErr_Format(PyExc_SystemError,
24222425
"unexpected flow_stmt: %d", TYPE(ch));

Python/ceval.c

+3
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,14 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
724724
#define TARGET_NOARG(op) \
725725
TARGET_##op: \
726726
opcode = op; \
727+
__attribute__ ((fallthrough)); \
727728
case op:\
728729

729730
#define TARGET(op) \
730731
TARGET_##op: \
731732
opcode = op; \
732733
oparg = NEXTARG(); \
734+
__attribute__ ((fallthrough)); \
733735
case op:\
734736

735737

@@ -2057,6 +2059,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
20572059
/* Fallthrough */
20582060
case 1:
20592061
w = POP(); /* exc */
2062+
__attribute__ ((fallthrough));
20602063
case 0: /* Fallthrough */
20612064
why = do_raise(w, v, u);
20622065
break;

Python/compile.c

+2
Original file line numberDiff line numberDiff line change
@@ -3079,12 +3079,14 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
30793079
switch (e->v.Attribute.ctx) {
30803080
case AugLoad:
30813081
ADDOP(c, DUP_TOP);
3082+
__attribute__ ((fallthrough));
30823083
/* Fall through to load */
30833084
case Load:
30843085
ADDOP_NAME(c, LOAD_ATTR, e->v.Attribute.attr, names);
30853086
break;
30863087
case AugStore:
30873088
ADDOP(c, ROT_TWO);
3089+
__attribute__ ((fallthrough));
30883090
/* Fall through to save */
30893091
case Store:
30903092
ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names);

Python/dtoa.c

+4
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,7 @@ _Py_dg_strtod(const char *s00, char **se)
15271527
switch (c) {
15281528
case '-':
15291529
sign = 1;
1530+
__attribute__ ((fallthrough));
15301531
/* no break */
15311532
case '+':
15321533
c = *++s;
@@ -1596,6 +1597,7 @@ _Py_dg_strtod(const char *s00, char **se)
15961597
switch (c) {
15971598
case '-':
15981599
esign = 1;
1600+
__attribute__ ((fallthrough));
15991601
/* no break */
16001602
case '+':
16011603
c = *++s;
@@ -2514,6 +2516,7 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
25142516
break;
25152517
case 2:
25162518
leftright = 0;
2519+
__attribute__ ((fallthrough));
25172520
/* no break */
25182521
case 4:
25192522
if (ndigits <= 0)
@@ -2522,6 +2525,7 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
25222525
break;
25232526
case 3:
25242527
leftright = 0;
2528+
__attribute__ ((fallthrough));
25252529
/* no break */
25262530
case 5:
25272531
i = ndigits + k + 1;

Python/getargs.c

+1
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,7 @@ skipitem(const char **p_format, va_list *p_va, int flags)
17361736
/* after 'e', only 's' and 't' is allowed */
17371737
goto err;
17381738
format++;
1739+
__attribute__ ((fallthrough));
17391740
/* explicit fallthrough to string cases */
17401741
}
17411742

0 commit comments

Comments
 (0)