]> granicus.if.org Git - python/commitdiff
[3.6] bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0...
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 12 Sep 2017 23:09:44 +0000 (16:09 -0700)
committerGitHub <noreply@github.com>
Tue, 12 Sep 2017 23:09:44 +0000 (16:09 -0700)
* bpo-30923: Disable warning that has been part of -Wextra since gcc-7.0. (#3142)

(cherry picked from commit d73a960c575207539c3f9765cff26d4fff400b45)

* bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. (#3157)

(cherry picked from commit f432a3234f9f2ee09bd40be03e06bf72865ee375)

* bpo-31275: Small refactoring to silence a fall-through warning. (#3206)

(cherry picked from commit 138753c1b96b5e06a5c5d409fa4cae5e2fe1108b)

14 files changed:
Modules/_ctypes/_ctypes.c
Modules/_decimal/libmpdec/io.c
Modules/cjkcodecs/_codecs_iso2022.c
Objects/stringlib/codecs.h
Objects/unicodeobject.c
Python/ast.c
Python/ceval.c
Python/compile.c
Python/dtoa.c
Python/formatter_unicode.c
Python/getargs.c
Python/marshal.c
Python/pyhash.c
Python/wordcode_helpers.h

index 2c01e374f19144df2523b04d25f964a509903a25..1ced6305d3d93f5a79464065b75ab8f3ff58ba14 100644 (file)
@@ -3675,7 +3675,7 @@ _build_callargs(PyCFuncPtrObject *self, PyObject *argtypes,
         case (PARAMFLAG_FIN | PARAMFLAG_FOUT):
             *pinoutmask |= (1 << i); /* mark as inout arg */
             (*pnumretvals)++;
-            /* fall through to PARAMFLAG_FIN... */
+            /* fall through */
         case 0:
         case PARAMFLAG_FIN:
             /* 'in' parameter.  Copy it from inargs. */
index 3aadfb0437979ce9fcb45a5362ab957c6c39f665..f45e558f1a9573448a9e4b9d73505cca7bb4d998 100644 (file)
    PEP-3101 formatting for numeric types. */
 
 
+/* Disable warning that is part of -Wextra since gcc 7.0. */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && __GNUC__ >= 7
+  #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
+
+
 /*
  * Work around the behavior of tolower() and strcasecmp() in certain
  * locales. For example, in tr_TR.utf8:
index 1ce4218f3089d082ed9816933039c02d078d505b..7394cf67e0e7dd561f4c7c99d101ce5768fcec52 100644 (file)
@@ -807,15 +807,9 @@ jisx0213_encoder(const Py_UCS4 *data, Py_ssize_t *length, void *config)
     case 2: /* second character of unicode pair */
         coded = find_pairencmap((ucs2_t)data[0], (ucs2_t)data[1],
                                 jisx0213_pair_encmap, JISX0213_ENCPAIRS);
-        if (coded == DBCINV) {
-            *length = 1;
-            coded = find_pairencmap((ucs2_t)data[0], 0,
-                      jisx0213_pair_encmap, JISX0213_ENCPAIRS);
-            if (coded == DBCINV)
-                return MAP_UNMAPPABLE;
-        }
-        else
+        if (coded != DBCINV)
             return coded;
+        /* fall through */
 
     case -1: /* flush unterminated */
         *length = 1;
index 43f2f3266fd7783a50af3dc9f04505ca5af3fa6b..f019d9a96bfba31e20c4f83ab3251ee9cfc67d8b 100644 (file)
@@ -330,7 +330,7 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
             case _Py_ERROR_REPLACE:
                 memset(p, '?', endpos - startpos);
                 p += (endpos - startpos);
-                /* fall through the ignore handler */
+                /* fall through */
             case _Py_ERROR_IGNORE:
                 i += (endpos - startpos - 1);
                 break;
@@ -378,7 +378,7 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
                 }
                 startpos = k;
                 assert(startpos < endpos);
-                /* fall through the default handler */
+                /* fall through */
             default:
                 rep = unicode_encode_call_errorhandler(
                       errors, &error_handler_obj, "utf-8", "surrogates not allowed",
index 1f221aff67c0d780aae360d8cdaeffca651209a1..e9fc6580383dde518807a30f3e342850e633bd36 100644 (file)
@@ -1779,6 +1779,7 @@ unicode_dealloc(PyObject *unicode)
 
     case SSTATE_INTERNED_IMMORTAL:
         Py_FatalError("Immortal interned string died.");
+        /* fall through */
 
     default:
         Py_FatalError("Inconsistent interned string state.");
@@ -6816,7 +6817,7 @@ unicode_encode_ucs1(PyObject *unicode,
             case _Py_ERROR_REPLACE:
                 memset(str, '?', collend - collstart);
                 str += (collend - collstart);
-                /* fall through ignore error handler */
+                /* fall through */
             case _Py_ERROR_IGNORE:
                 pos = collend;
                 break;
@@ -6855,7 +6856,7 @@ unicode_encode_ucs1(PyObject *unicode,
                     break;
                 collstart = pos;
                 assert(collstart != collend);
-                /* fallback to general error handling */
+                /* fall through */
 
             default:
                 rep = unicode_encode_call_errorhandler(errors, &error_handler_obj,
index 4fa68a371d402dcb45194619c845e315a0a00a2a..aa4acc9b2610a7886b806908403b38488b78b7d2 100644 (file)
@@ -1175,6 +1175,7 @@ ast_for_comp_op(struct compiling *c, const node *n)
                     return In;
                 if (strcmp(STR(n), "is") == 0)
                     return Is;
+                /* fall through */
             default:
                 PyErr_Format(PyExc_SystemError, "invalid comp_op: %s",
                              STR(n));
@@ -1189,6 +1190,7 @@ ast_for_comp_op(struct compiling *c, const node *n)
                     return NotIn;
                 if (strcmp(STR(CHILD(n, 0)), "is") == 0)
                     return IsNot;
+                /* fall through */
             default:
                 PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s",
                              STR(CHILD(n, 0)), STR(CHILD(n, 1)));
@@ -3149,6 +3151,7 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
                 }
                 return Raise(expression, cause, LINENO(n), n->n_col_offset, c->c_arena);
             }
+            /* fall through */
         default:
             PyErr_Format(PyExc_SystemError,
                          "unexpected flow_stmt: %d", TYPE(ch));
index 2b74d0e5730f427787e79ea91448f27f9e624415..b6ad444e70be2254b68ba592638571ae61482412 100644 (file)
@@ -1875,9 +1875,11 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
             switch (oparg) {
             case 2:
                 cause = POP(); /* cause */
+                /* fall through */
             case 1:
                 exc = POP(); /* exc */
-            case 0: /* Fallthrough */
+                /* fall through */
+            case 0:
                 if (do_raise(exc, cause)) {
                     why = WHY_EXCEPTION;
                     goto fast_block_end;
index 6255ec7d47f5a20b8c39b2f92932a37f89dbac46..797a1840e6a7f23e3a9c076c684aec8a2d8239aa 100644 (file)
@@ -4069,6 +4069,7 @@ expr_constant(struct compiler *c, expr_ty e)
         else if (o == Py_False)
             return 0;
     }
+    /* fall through */
     default:
         return -1;
     }
@@ -4361,13 +4362,13 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
         switch (e->v.Attribute.ctx) {
         case AugLoad:
             ADDOP(c, DUP_TOP);
-            /* Fall through to load */
+            /* Fall through */
         case Load:
             ADDOP_NAME(c, LOAD_ATTR, e->v.Attribute.attr, names);
             break;
         case AugStore:
             ADDOP(c, ROT_TWO);
-            /* Fall through to save */
+            /* Fall through */
         case Store:
             ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names);
             break;
index efcadc31e9c5b1ccb2b7778fa8b3d6b29e447103..01ca9b0b22fbeb09190720c97d27e961f161dc01 100644 (file)
@@ -1454,7 +1454,7 @@ _Py_dg_strtod(const char *s00, char **se)
     switch (c) {
     case '-':
         sign = 1;
-        /* no break */
+        /* fall through */
     case '+':
         c = *++s;
     }
@@ -1523,7 +1523,7 @@ _Py_dg_strtod(const char *s00, char **se)
         switch (c) {
         case '-':
             esign = 1;
-            /* no break */
+            /* fall through */
         case '+':
             c = *++s;
         }
@@ -2441,7 +2441,7 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
         break;
     case 2:
         leftright = 0;
-        /* no break */
+        /* fall through */
     case 4:
         if (ndigits <= 0)
             ndigits = 1;
@@ -2449,7 +2449,7 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
         break;
     case 3:
         leftright = 0;
-        /* no break */
+        /* fall through */
     case 5:
         i = ndigits + k + 1;
         ilim = i;
index a2c2b3627c9ec74cebdf698962e73f170919c4d6..9192bfd6a670fbc30fa7cfa68551f58ad3e7b3fa 100644 (file)
@@ -312,6 +312,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
                 format->thousands_separators = LT_UNDER_FOUR_LOCALE;
                 break;
             }
+            /* fall through */
         default:
             invalid_comma_type(format->type);
             return 0;
index 13819642060b4947f588f0de4f995d7396d1e7cd..ed6b8152de453e5da13c8de87cb6669b79d4869e 100644 (file)
@@ -2260,8 +2260,8 @@ skipitem(const char **p_format, va_list *p_va, int flags)
                 /* after 'e', only 's' and 't' is allowed */
                 goto err;
             format++;
-            /* explicit fallthrough to string cases */
         }
+        /* fall through */
 
     case 's': /* string */
     case 'z': /* string or None */
index 7b12ab7510dcfb2e030eb7dc58febbad961d557a..22ca49c75629edc783844909655115b723466231 100644 (file)
@@ -1105,6 +1105,7 @@ r_object(RFILE *p)
 
     case TYPE_ASCII_INTERNED:
         is_interned = 1;
+        /* fall through */
     case TYPE_ASCII:
         n = r_long(p);
         if (PyErr_Occurred())
@@ -1117,6 +1118,7 @@ r_object(RFILE *p)
 
     case TYPE_SHORT_ASCII_INTERNED:
         is_interned = 1;
+        /* fall through */
     case TYPE_SHORT_ASCII:
         n = r_byte(p);
         if (n == EOF) {
@@ -1142,6 +1144,7 @@ r_object(RFILE *p)
 
     case TYPE_INTERNED:
         is_interned = 1;
+        /* fall through */
     case TYPE_UNICODE:
         {
         const char *buffer;
index 57a2da715e17f09875c7416d66ddbdde54244ebc..a2ec2309c706bcc458b5b7e2bf14a10d46452a9c 100644 (file)
@@ -393,13 +393,13 @@ siphash24(const void *src, Py_ssize_t src_sz) {
     pt = (uint8_t *)&t;
     m = (uint8_t *)in;
     switch (src_sz) {
-        case 7: pt[6] = m[6];
-        case 6: pt[5] = m[5];
-        case 5: pt[4] = m[4];
+        case 7: pt[6] = m[6]; /* fall through */
+        case 6: pt[5] = m[5]; /* fall through */
+        case 5: pt[4] = m[4]; /* fall through */
         case 4: memcpy(pt, m, sizeof(uint32_t)); break;
-        case 3: pt[2] = m[2];
-        case 2: pt[1] = m[1];
-        case 1: pt[0] = m[0];
+        case 3: pt[2] = m[2]; /* fall through */
+        case 2: pt[1] = m[1]; /* fall through */
+        case 1: pt[0] = m[0]; /* fall through */
     }
     b |= _le64toh(t);
 
index b0e3a917767f1b3043e881161e7d87fe30195f4d..cce81c1d24e55dbcf080749a19adf95a891bdadf 100644 (file)
@@ -28,10 +28,13 @@ write_op_arg(_Py_CODEUNIT *codestr, unsigned char opcode,
     switch (ilen) {
         case 4:
             *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 24) & 0xff);
+            /* fall through */
         case 3:
             *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 16) & 0xff);
+            /* fall through */
         case 2:
             *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 8) & 0xff);
+            /* fall through */
         case 1:
             *codestr++ = PACKOPARG(opcode, oparg & 0xff);
             break;