mirror of https://github.com/python/cpython
gh-121040: Use __attribute__((fallthrough)) (#121044)
Fix warnings when using -Wimplicit-fallthrough compiler flag. Annotate explicitly "fall through" switch cases with a new _Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if available. Replace "fall through" comments with _Py_FALLTHROUGH. Add _Py__has_attribute() macro. No longer define __has_attribute() macro if it's not defined. Move also _Py__has_builtin() at the top of pyport.h. Co-Authored-By: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
4999e0bda0
commit
12af8ec864
|
@ -41,11 +41,8 @@
|
||||||
* we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions
|
* we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions
|
||||||
* have 4 < gcc < 5.
|
* have 4 < gcc < 5.
|
||||||
*/
|
*/
|
||||||
#ifndef __has_attribute
|
|
||||||
#define __has_attribute(x) 0 // Compatibility with non-clang compilers.
|
|
||||||
#endif
|
|
||||||
#if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\
|
#if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\
|
||||||
(defined(__clang__) && __has_attribute(visibility))
|
(defined(__clang__) && _Py__has_attribute(visibility))
|
||||||
#define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default")))
|
#define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default")))
|
||||||
#define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
|
#define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
|
||||||
#define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden")))
|
#define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden")))
|
||||||
|
|
|
@ -9,6 +9,24 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Preprocessor check for a builtin preprocessor function. Always return 0
|
||||||
|
// if __has_builtin() macro is not defined.
|
||||||
|
//
|
||||||
|
// __has_builtin() is available on clang and GCC 10.
|
||||||
|
#ifdef __has_builtin
|
||||||
|
# define _Py__has_builtin(x) __has_builtin(x)
|
||||||
|
#else
|
||||||
|
# define _Py__has_builtin(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Preprocessor check for a compiler __attribute__. Always return 0
|
||||||
|
// if __has_attribute() macro is not defined.
|
||||||
|
#ifdef __has_attribute
|
||||||
|
# define _Py__has_attribute(x) __has_attribute(x)
|
||||||
|
#else
|
||||||
|
# define _Py__has_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// Macro to use C++ static_cast<> in the Python C API.
|
// Macro to use C++ static_cast<> in the Python C API.
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# define _Py_STATIC_CAST(type, expr) static_cast<type>(expr)
|
# define _Py_STATIC_CAST(type, expr) static_cast<type>(expr)
|
||||||
|
@ -532,16 +550,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Preprocessor check for a builtin preprocessor function. Always return 0
|
|
||||||
// if __has_builtin() macro is not defined.
|
|
||||||
//
|
|
||||||
// __has_builtin() is available on clang and GCC 10.
|
|
||||||
#ifdef __has_builtin
|
|
||||||
# define _Py__has_builtin(x) __has_builtin(x)
|
|
||||||
#else
|
|
||||||
# define _Py__has_builtin(x) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// _Py_TYPEOF(expr) gets the type of an expression.
|
// _Py_TYPEOF(expr) gets the type of an expression.
|
||||||
//
|
//
|
||||||
// Example: _Py_TYPEOF(x) x_copy = (x);
|
// Example: _Py_TYPEOF(x) x_copy = (x);
|
||||||
|
@ -607,4 +615,21 @@ extern "C" {
|
||||||
# define _SGI_MP_SOURCE
|
# define _SGI_MP_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Explicit fallthrough in switch case to avoid warnings
|
||||||
|
// with compiler flag -Wimplicit-fallthrough.
|
||||||
|
//
|
||||||
|
// Usage example:
|
||||||
|
//
|
||||||
|
// switch (value) {
|
||||||
|
// case 1: _Py_FALLTHROUGH;
|
||||||
|
// case 2: code; break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// __attribute__((fallthrough)) was introduced in GCC 7.
|
||||||
|
#if _Py__has_attribute(fallthrough)
|
||||||
|
# define _Py_FALLTHROUGH __attribute__((fallthrough))
|
||||||
|
#else
|
||||||
|
# define _Py_FALLTHROUGH do { } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* Py_PYPORT_H */
|
#endif /* Py_PYPORT_H */
|
||||||
|
|
|
@ -731,7 +731,7 @@ parse_process_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
|
||||||
}
|
}
|
||||||
/* normal character - handle as START_FIELD */
|
/* normal character - handle as START_FIELD */
|
||||||
self->state = START_FIELD;
|
self->state = START_FIELD;
|
||||||
/* fallthru */
|
_Py_FALLTHROUGH;
|
||||||
case START_FIELD:
|
case START_FIELD:
|
||||||
/* expecting field */
|
/* expecting field */
|
||||||
self->unquoted_field = true;
|
self->unquoted_field = true;
|
||||||
|
@ -785,7 +785,7 @@ parse_process_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
|
||||||
case AFTER_ESCAPED_CRNL:
|
case AFTER_ESCAPED_CRNL:
|
||||||
if (c == EOL)
|
if (c == EOL)
|
||||||
break;
|
break;
|
||||||
/*fallthru*/
|
_Py_FALLTHROUGH;
|
||||||
|
|
||||||
case IN_FIELD:
|
case IN_FIELD:
|
||||||
/* in unquoted field */
|
/* in unquoted field */
|
||||||
|
|
|
@ -4074,7 +4074,7 @@ _build_callargs(ctypes_state *st, PyCFuncPtrObject *self, PyObject *argtypes,
|
||||||
case (PARAMFLAG_FIN | PARAMFLAG_FOUT):
|
case (PARAMFLAG_FIN | PARAMFLAG_FOUT):
|
||||||
*pinoutmask |= (1 << i); /* mark as inout arg */
|
*pinoutmask |= (1 << i); /* mark as inout arg */
|
||||||
(*pnumretvals)++;
|
(*pnumretvals)++;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 0:
|
case 0:
|
||||||
case PARAMFLAG_FIN:
|
case PARAMFLAG_FIN:
|
||||||
/* 'in' parameter. Copy it from inargs. */
|
/* 'in' parameter. Copy it from inargs. */
|
||||||
|
|
|
@ -485,10 +485,11 @@ PyCStructUnionType_update_stginfo(PyObject *type, PyObject *fields, int isStruct
|
||||||
case FFI_TYPE_SINT16:
|
case FFI_TYPE_SINT16:
|
||||||
case FFI_TYPE_SINT32:
|
case FFI_TYPE_SINT32:
|
||||||
if (info->getfunc != _ctypes_get_fielddesc("c")->getfunc
|
if (info->getfunc != _ctypes_get_fielddesc("c")->getfunc
|
||||||
&& info->getfunc != _ctypes_get_fielddesc("u")->getfunc
|
&& info->getfunc != _ctypes_get_fielddesc("u")->getfunc)
|
||||||
)
|
{
|
||||||
break;
|
break;
|
||||||
/* else fall through */
|
}
|
||||||
|
_Py_FALLTHROUGH; /* else fall through */
|
||||||
default:
|
default:
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"bit fields not allowed for type %s",
|
"bit fields not allowed for type %s",
|
||||||
|
|
|
@ -363,7 +363,7 @@ handle_queue_error(int err, PyObject *mod, int64_t qid)
|
||||||
|
|
||||||
module_state *state;
|
module_state *state;
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case ERR_QUEUE_ALLOC: // fall through
|
case ERR_QUEUE_ALLOC: _Py_FALLTHROUGH;
|
||||||
case ERR_QUEUES_ALLOC:
|
case ERR_QUEUES_ALLOC:
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3472,8 +3472,8 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(self->protocol) {
|
switch(self->protocol) {
|
||||||
case PY_SSL_VERSION_TLS_CLIENT: /* fall through */
|
case PY_SSL_VERSION_TLS_CLIENT: _Py_FALLTHROUGH;
|
||||||
case PY_SSL_VERSION_TLS_SERVER: /* fall through */
|
case PY_SSL_VERSION_TLS_SERVER: _Py_FALLTHROUGH;
|
||||||
case PY_SSL_VERSION_TLS:
|
case PY_SSL_VERSION_TLS:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1373,7 +1373,7 @@ whichtable(const char **pfmt)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
--*pfmt; /* Back out of pointer increment */
|
--*pfmt; /* Back out of pointer increment */
|
||||||
/* Fall through */
|
_Py_FALLTHROUGH;
|
||||||
case '@':
|
case '@':
|
||||||
return native_table;
|
return native_table;
|
||||||
}
|
}
|
||||||
|
@ -1475,7 +1475,7 @@ prepare_s(PyStructObject *self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 's': /* fall through */
|
case 's': _Py_FALLTHROUGH;
|
||||||
case 'p': len++; ncodes++; break;
|
case 'p': len++; ncodes++; break;
|
||||||
case 'x': break;
|
case 'x': break;
|
||||||
default: len += num; if (num) ncodes++; break;
|
default: len += num; if (num) ncodes++; break;
|
||||||
|
|
|
@ -34,11 +34,11 @@ err_restore(PyObject *self, PyObject *args) {
|
||||||
case 3:
|
case 3:
|
||||||
traceback = PyTuple_GetItem(args, 2);
|
traceback = PyTuple_GetItem(args, 2);
|
||||||
Py_INCREF(traceback);
|
Py_INCREF(traceback);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 2:
|
case 2:
|
||||||
value = PyTuple_GetItem(args, 1);
|
value = PyTuple_GetItem(args, 1);
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 1:
|
case 1:
|
||||||
type = PyTuple_GetItem(args, 0);
|
type = PyTuple_GetItem(args, 0);
|
||||||
Py_INCREF(type);
|
Py_INCREF(type);
|
||||||
|
|
|
@ -806,7 +806,7 @@ jisx0213_encoder(const MultibyteCodec *codec, const Py_UCS4 *data,
|
||||||
jisx0213_pair_encmap, JISX0213_ENCPAIRS);
|
jisx0213_pair_encmap, JISX0213_ENCPAIRS);
|
||||||
if (coded != DBCINV)
|
if (coded != DBCINV)
|
||||||
return coded;
|
return coded;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
|
|
||||||
case -1: /* flush unterminated */
|
case -1: /* flush unterminated */
|
||||||
*length = 1;
|
*length = 1;
|
||||||
|
|
|
@ -923,7 +923,7 @@ _overlapped_Overlapped_getresult_impl(OverlappedObject *self, BOOL wait)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
return SetFromWindowsErr(err);
|
return SetFromWindowsErr(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1887,12 +1887,14 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
||||||
|
|
||||||
#ifdef AF_RDS
|
#ifdef AF_RDS
|
||||||
case AF_RDS:
|
case AF_RDS:
|
||||||
/* RDS sockets use sockaddr_in: fall-through */
|
/* RDS sockets use sockaddr_in */
|
||||||
|
_Py_FALLTHROUGH;
|
||||||
#endif /* AF_RDS */
|
#endif /* AF_RDS */
|
||||||
|
|
||||||
#ifdef AF_DIVERT
|
#ifdef AF_DIVERT
|
||||||
case AF_DIVERT:
|
case AF_DIVERT:
|
||||||
/* FreeBSD divert(4) sockets use sockaddr_in: fall-through */
|
/* FreeBSD divert(4) sockets use sockaddr_in */
|
||||||
|
_Py_FALLTHROUGH;
|
||||||
#endif /* AF_DIVERT */
|
#endif /* AF_DIVERT */
|
||||||
|
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
@ -2214,7 +2216,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
||||||
switch (s->sock_proto) {
|
switch (s->sock_proto) {
|
||||||
#ifdef CAN_RAW
|
#ifdef CAN_RAW
|
||||||
case CAN_RAW:
|
case CAN_RAW:
|
||||||
/* fall-through */
|
_Py_FALLTHROUGH;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CAN_BCM
|
#ifdef CAN_BCM
|
||||||
case CAN_BCM:
|
case CAN_BCM:
|
||||||
|
@ -2590,7 +2592,8 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
|
||||||
|
|
||||||
#ifdef AF_RDS
|
#ifdef AF_RDS
|
||||||
case AF_RDS:
|
case AF_RDS:
|
||||||
/* RDS sockets use sockaddr_in: fall-through */
|
/* RDS sockets use sockaddr_in */
|
||||||
|
_Py_FALLTHROUGH;
|
||||||
#endif /* AF_RDS */
|
#endif /* AF_RDS */
|
||||||
|
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
|
|
@ -489,8 +489,8 @@ zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits,
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case Z_OK: /* fall through */
|
case Z_OK: _Py_FALLTHROUGH;
|
||||||
case Z_BUF_ERROR: /* fall through */
|
case Z_BUF_ERROR: _Py_FALLTHROUGH;
|
||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
break;
|
break;
|
||||||
case Z_MEM_ERROR:
|
case Z_MEM_ERROR:
|
||||||
|
@ -915,8 +915,8 @@ zlib_Decompress_decompress_impl(compobject *self, PyTypeObject *cls,
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case Z_OK: /* fall through */
|
case Z_OK: _Py_FALLTHROUGH;
|
||||||
case Z_BUF_ERROR: /* fall through */
|
case Z_BUF_ERROR: _Py_FALLTHROUGH;
|
||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1293,8 +1293,8 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls,
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case Z_OK: /* fall through */
|
case Z_OK: _Py_FALLTHROUGH;
|
||||||
case Z_BUF_ERROR: /* fall through */
|
case Z_BUF_ERROR: _Py_FALLTHROUGH;
|
||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1495,8 +1495,8 @@ decompress_buf(ZlibDecompressor *self, Py_ssize_t max_length)
|
||||||
err = inflate(&self->zst, Z_SYNC_FLUSH);
|
err = inflate(&self->zst, Z_SYNC_FLUSH);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case Z_OK: /* fall through */
|
case Z_OK: _Py_FALLTHROUGH;
|
||||||
case Z_BUF_ERROR: /* fall through */
|
case Z_BUF_ERROR: _Py_FALLTHROUGH;
|
||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -83,7 +83,7 @@ range_from_array(PyTypeObject *type, PyObject *const *args, Py_ssize_t num_args)
|
||||||
switch (num_args) {
|
switch (num_args) {
|
||||||
case 3:
|
case 3:
|
||||||
step = args[2];
|
step = args[2];
|
||||||
/* fallthrough */
|
_Py_FALLTHROUGH;
|
||||||
case 2:
|
case 2:
|
||||||
/* Convert borrowed refs to owned refs */
|
/* Convert borrowed refs to owned refs */
|
||||||
start = PyNumber_Index(args[0]);
|
start = PyNumber_Index(args[0]);
|
||||||
|
|
|
@ -331,7 +331,7 @@ STRINGLIB(utf8_encoder)(_PyBytesWriter *writer,
|
||||||
case _Py_ERROR_REPLACE:
|
case _Py_ERROR_REPLACE:
|
||||||
memset(p, '?', endpos - startpos);
|
memset(p, '?', endpos - startpos);
|
||||||
p += (endpos - startpos);
|
p += (endpos - startpos);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case _Py_ERROR_IGNORE:
|
case _Py_ERROR_IGNORE:
|
||||||
i += (endpos - startpos - 1);
|
i += (endpos - startpos - 1);
|
||||||
break;
|
break;
|
||||||
|
@ -379,7 +379,7 @@ STRINGLIB(utf8_encoder)(_PyBytesWriter *writer,
|
||||||
}
|
}
|
||||||
startpos = k;
|
startpos = k;
|
||||||
assert(startpos < endpos);
|
assert(startpos < endpos);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
rep = unicode_encode_call_errorhandler(
|
rep = unicode_encode_call_errorhandler(
|
||||||
errors, &error_handler_obj, "utf-8", "surrogates not allowed",
|
errors, &error_handler_obj, "utf-8", "surrogates not allowed",
|
||||||
|
|
|
@ -5073,7 +5073,7 @@ unicode_decode_utf8_impl(_PyUnicodeWriter *writer,
|
||||||
/* Truncated surrogate code in range D800-DFFF */
|
/* Truncated surrogate code in range D800-DFFF */
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
errmsg = "invalid continuation byte";
|
errmsg = "invalid continuation byte";
|
||||||
|
@ -7108,7 +7108,7 @@ unicode_encode_ucs1(PyObject *unicode,
|
||||||
case _Py_ERROR_REPLACE:
|
case _Py_ERROR_REPLACE:
|
||||||
memset(str, '?', collend - collstart);
|
memset(str, '?', collend - collstart);
|
||||||
str += (collend - collstart);
|
str += (collend - collstart);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case _Py_ERROR_IGNORE:
|
case _Py_ERROR_IGNORE:
|
||||||
pos = collend;
|
pos = collend;
|
||||||
break;
|
break;
|
||||||
|
@ -7147,7 +7147,7 @@ unicode_encode_ucs1(PyObject *unicode,
|
||||||
break;
|
break;
|
||||||
collstart = pos;
|
collstart = pos;
|
||||||
assert(collstart != collend);
|
assert(collstart != collend);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rep = unicode_encode_call_errorhandler(errors, &error_handler_obj,
|
rep = unicode_encode_call_errorhandler(errors, &error_handler_obj,
|
||||||
|
@ -8699,7 +8699,7 @@ charmap_encoding_error(
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case _Py_ERROR_IGNORE:
|
case _Py_ERROR_IGNORE:
|
||||||
*inpos = collendpos;
|
*inpos = collendpos;
|
||||||
break;
|
break;
|
||||||
|
@ -15673,7 +15673,7 @@ _PyUnicode_ClearInterned(PyInterpreterState *interp)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case SSTATE_NOT_INTERNED:
|
case SSTATE_NOT_INTERNED:
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
Py_UNREACHABLE();
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,17 +369,17 @@ write_instr(_Py_CODEUNIT *codestr, instruction *instr, int ilen)
|
||||||
codestr->op.code = EXTENDED_ARG;
|
codestr->op.code = EXTENDED_ARG;
|
||||||
codestr->op.arg = (oparg >> 24) & 0xFF;
|
codestr->op.arg = (oparg >> 24) & 0xFF;
|
||||||
codestr++;
|
codestr++;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 3:
|
case 3:
|
||||||
codestr->op.code = EXTENDED_ARG;
|
codestr->op.code = EXTENDED_ARG;
|
||||||
codestr->op.arg = (oparg >> 16) & 0xFF;
|
codestr->op.arg = (oparg >> 16) & 0xFF;
|
||||||
codestr++;
|
codestr++;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 2:
|
case 2:
|
||||||
codestr->op.code = EXTENDED_ARG;
|
codestr->op.code = EXTENDED_ARG;
|
||||||
codestr->op.arg = (oparg >> 8) & 0xFF;
|
codestr->op.arg = (oparg >> 8) & 0xFF;
|
||||||
codestr++;
|
codestr++;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 1:
|
case 1:
|
||||||
codestr->op.code = opcode;
|
codestr->op.code = opcode;
|
||||||
codestr->op.arg = oparg & 0xFF;
|
codestr->op.arg = oparg & 0xFF;
|
||||||
|
|
|
@ -885,10 +885,10 @@ dummy_func(
|
||||||
switch (oparg) {
|
switch (oparg) {
|
||||||
case 2:
|
case 2:
|
||||||
cause = PyStackRef_AsPyObjectSteal(args[1]);
|
cause = PyStackRef_AsPyObjectSteal(args[1]);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 1:
|
case 1:
|
||||||
exc = PyStackRef_AsPyObjectSteal(args[0]);
|
exc = PyStackRef_AsPyObjectSteal(args[0]);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 0:
|
case 0:
|
||||||
if (do_raise(tstate, exc, cause)) {
|
if (do_raise(tstate, exc, cause)) {
|
||||||
assert(oparg == 0);
|
assert(oparg == 0);
|
||||||
|
|
|
@ -4681,7 +4681,7 @@ check_subscripter(struct compiler *c, expr_ty e)
|
||||||
{
|
{
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case Set_kind:
|
case Set_kind:
|
||||||
case SetComp_kind:
|
case SetComp_kind:
|
||||||
case GeneratorExp_kind:
|
case GeneratorExp_kind:
|
||||||
|
@ -4714,7 +4714,7 @@ check_index(struct compiler *c, expr_ty e, expr_ty s)
|
||||||
if (!(PyUnicode_Check(v) || PyBytes_Check(v) || PyTuple_Check(v))) {
|
if (!(PyUnicode_Check(v) || PyBytes_Check(v) || PyTuple_Check(v))) {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case Tuple_kind:
|
case Tuple_kind:
|
||||||
case List_kind:
|
case List_kind:
|
||||||
case ListComp_kind:
|
case ListComp_kind:
|
||||||
|
|
|
@ -969,7 +969,7 @@ _PyXI_ApplyErrorCode(_PyXI_errcode code, PyInterpreterState *interp)
|
||||||
{
|
{
|
||||||
assert(!PyErr_Occurred());
|
assert(!PyErr_Occurred());
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case _PyXI_ERR_NO_ERROR: // fall through
|
case _PyXI_ERR_NO_ERROR: _Py_FALLTHROUGH;
|
||||||
case _PyXI_ERR_UNCAUGHT_EXCEPTION:
|
case _PyXI_ERR_UNCAUGHT_EXCEPTION:
|
||||||
// There is nothing to apply.
|
// There is nothing to apply.
|
||||||
#ifdef Py_DEBUG
|
#ifdef Py_DEBUG
|
||||||
|
|
|
@ -1405,7 +1405,7 @@ _Py_dg_strtod(const char *s00, char **se)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-':
|
||||||
sign = 1;
|
sign = 1;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case '+':
|
case '+':
|
||||||
c = *++s;
|
c = *++s;
|
||||||
}
|
}
|
||||||
|
@ -1474,7 +1474,7 @@ _Py_dg_strtod(const char *s00, char **se)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-':
|
||||||
esign = 1;
|
esign = 1;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case '+':
|
case '+':
|
||||||
c = *++s;
|
c = *++s;
|
||||||
}
|
}
|
||||||
|
@ -2362,7 +2362,7 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
leftright = 0;
|
leftright = 0;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 4:
|
case 4:
|
||||||
if (ndigits <= 0)
|
if (ndigits <= 0)
|
||||||
ndigits = 1;
|
ndigits = 1;
|
||||||
|
@ -2370,7 +2370,7 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
leftright = 0;
|
leftright = 0;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 5:
|
case 5:
|
||||||
i = ndigits + k + 1;
|
i = ndigits + k + 1;
|
||||||
ilim = i;
|
ilim = i;
|
||||||
|
|
|
@ -320,7 +320,7 @@ parse_internal_render_format_spec(PyObject *obj,
|
||||||
format->thousands_separators = LT_UNDER_FOUR_LOCALE;
|
format->thousands_separators = LT_UNDER_FOUR_LOCALE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
invalid_thousands_separator_type(format->thousands_separators, format->type);
|
invalid_thousands_separator_type(format->thousands_separators, format->type);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -5532,10 +5532,10 @@
|
||||||
switch (oparg) {
|
switch (oparg) {
|
||||||
case 2:
|
case 2:
|
||||||
cause = PyStackRef_AsPyObjectSteal(args[1]);
|
cause = PyStackRef_AsPyObjectSteal(args[1]);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 1:
|
case 1:
|
||||||
exc = PyStackRef_AsPyObjectSteal(args[0]);
|
exc = PyStackRef_AsPyObjectSteal(args[0]);
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case 0:
|
case 0:
|
||||||
if (do_raise(tstate, exc, cause)) {
|
if (do_raise(tstate, exc, cause)) {
|
||||||
assert(oparg == 0);
|
assert(oparg == 0);
|
||||||
|
|
|
@ -2676,7 +2676,7 @@ skipitem(const char **p_format, va_list *p_va, int flags)
|
||||||
goto err;
|
goto err;
|
||||||
format++;
|
format++;
|
||||||
}
|
}
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
|
|
||||||
case 's': /* string */
|
case 's': /* string */
|
||||||
case 'z': /* string or None */
|
case 'z': /* string or None */
|
||||||
|
|
|
@ -248,14 +248,14 @@ _Py_ext_module_loader_result_set_error(
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case _Py_ext_module_loader_result_EXCEPTION: /* fall through */
|
case _Py_ext_module_loader_result_EXCEPTION: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_UNREPORTED_EXC:
|
case _Py_ext_module_loader_result_ERR_UNREPORTED_EXC:
|
||||||
assert(PyErr_Occurred());
|
assert(PyErr_Occurred());
|
||||||
break;
|
break;
|
||||||
case _Py_ext_module_loader_result_ERR_MISSING: /* fall through */
|
case _Py_ext_module_loader_result_ERR_MISSING: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_UNINITIALIZED: /* fall through */
|
case _Py_ext_module_loader_result_ERR_UNINITIALIZED: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE: /* fall through */
|
case _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_NOT_MODULE: /* fall through */
|
case _Py_ext_module_loader_result_ERR_NOT_MODULE: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_MISSING_DEF:
|
case _Py_ext_module_loader_result_ERR_MISSING_DEF:
|
||||||
assert(!PyErr_Occurred());
|
assert(!PyErr_Occurred());
|
||||||
break;
|
break;
|
||||||
|
@ -279,11 +279,11 @@ _Py_ext_module_loader_result_set_error(
|
||||||
res->kind = _Py_ext_module_kind_INVALID;
|
res->kind = _Py_ext_module_kind_INVALID;
|
||||||
break;
|
break;
|
||||||
/* None of the rest affect the result kind. */
|
/* None of the rest affect the result kind. */
|
||||||
case _Py_ext_module_loader_result_EXCEPTION: /* fall through */
|
case _Py_ext_module_loader_result_EXCEPTION: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_MISSING: /* fall through */
|
case _Py_ext_module_loader_result_ERR_MISSING: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_UNREPORTED_EXC: /* fall through */
|
case _Py_ext_module_loader_result_ERR_UNREPORTED_EXC: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE: /* fall through */
|
case _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_NOT_MODULE: /* fall through */
|
case _Py_ext_module_loader_result_ERR_NOT_MODULE: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_MISSING_DEF:
|
case _Py_ext_module_loader_result_ERR_MISSING_DEF:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -307,14 +307,14 @@ _Py_ext_module_loader_result_apply_error(
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
switch (err.kind) {
|
switch (err.kind) {
|
||||||
case _Py_ext_module_loader_result_EXCEPTION: /* fall through */
|
case _Py_ext_module_loader_result_EXCEPTION: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_UNREPORTED_EXC:
|
case _Py_ext_module_loader_result_ERR_UNREPORTED_EXC:
|
||||||
assert(err.exc != NULL);
|
assert(err.exc != NULL);
|
||||||
break;
|
break;
|
||||||
case _Py_ext_module_loader_result_ERR_MISSING: /* fall through */
|
case _Py_ext_module_loader_result_ERR_MISSING: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_UNINITIALIZED: /* fall through */
|
case _Py_ext_module_loader_result_ERR_UNINITIALIZED: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE: /* fall through */
|
case _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_NOT_MODULE: /* fall through */
|
case _Py_ext_module_loader_result_ERR_NOT_MODULE: _Py_FALLTHROUGH;
|
||||||
case _Py_ext_module_loader_result_ERR_MISSING_DEF:
|
case _Py_ext_module_loader_result_ERR_MISSING_DEF:
|
||||||
assert(err.exc == NULL);
|
assert(err.exc == NULL);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ r_object(RFILE *p)
|
||||||
|
|
||||||
case TYPE_ASCII_INTERNED:
|
case TYPE_ASCII_INTERNED:
|
||||||
is_interned = 1;
|
is_interned = 1;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case TYPE_ASCII:
|
case TYPE_ASCII:
|
||||||
n = r_long(p);
|
n = r_long(p);
|
||||||
if (n < 0 || n > SIZE32_MAX) {
|
if (n < 0 || n > SIZE32_MAX) {
|
||||||
|
@ -1170,7 +1170,7 @@ r_object(RFILE *p)
|
||||||
|
|
||||||
case TYPE_SHORT_ASCII_INTERNED:
|
case TYPE_SHORT_ASCII_INTERNED:
|
||||||
is_interned = 1;
|
is_interned = 1;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case TYPE_SHORT_ASCII:
|
case TYPE_SHORT_ASCII:
|
||||||
n = r_byte(p);
|
n = r_byte(p);
|
||||||
if (n == EOF) {
|
if (n == EOF) {
|
||||||
|
@ -1198,7 +1198,7 @@ r_object(RFILE *p)
|
||||||
|
|
||||||
case TYPE_INTERNED:
|
case TYPE_INTERNED:
|
||||||
is_interned = 1;
|
is_interned = 1;
|
||||||
/* fall through */
|
_Py_FALLTHROUGH;
|
||||||
case TYPE_UNICODE:
|
case TYPE_UNICODE:
|
||||||
{
|
{
|
||||||
const char *buffer;
|
const char *buffer;
|
||||||
|
|
|
@ -306,6 +306,7 @@ do_mkvalue(const char **p_format, va_list *p_va)
|
||||||
return PyLong_FromSsize_t(va_arg(*p_va, Py_ssize_t));
|
return PyLong_FromSsize_t(va_arg(*p_va, Py_ssize_t));
|
||||||
#endif
|
#endif
|
||||||
/* Fall through from 'n' to 'l' if Py_ssize_t is long */
|
/* Fall through from 'n' to 'l' if Py_ssize_t is long */
|
||||||
|
_Py_FALLTHROUGH;
|
||||||
case 'l':
|
case 'l':
|
||||||
return PyLong_FromLong(va_arg(*p_va, long));
|
return PyLong_FromLong(va_arg(*p_va, long));
|
||||||
|
|
||||||
|
|
|
@ -170,12 +170,12 @@ _Py_HashBytes(const void *src, Py_ssize_t len)
|
||||||
|
|
||||||
switch(len) {
|
switch(len) {
|
||||||
/* ((hash << 5) + hash) + *p == hash * 33 + *p */
|
/* ((hash << 5) + hash) + *p == hash * 33 + *p */
|
||||||
case 7: hash = ((hash << 5) + hash) + *p++; /* fallthrough */
|
case 7: hash = ((hash << 5) + hash) + *p++; _Py_FALLTHROUGH;
|
||||||
case 6: hash = ((hash << 5) + hash) + *p++; /* fallthrough */
|
case 6: hash = ((hash << 5) + hash) + *p++; _Py_FALLTHROUGH;
|
||||||
case 5: hash = ((hash << 5) + hash) + *p++; /* fallthrough */
|
case 5: hash = ((hash << 5) + hash) + *p++; _Py_FALLTHROUGH;
|
||||||
case 4: hash = ((hash << 5) + hash) + *p++; /* fallthrough */
|
case 4: hash = ((hash << 5) + hash) + *p++; _Py_FALLTHROUGH;
|
||||||
case 3: hash = ((hash << 5) + hash) + *p++; /* fallthrough */
|
case 3: hash = ((hash << 5) + hash) + *p++; _Py_FALLTHROUGH;
|
||||||
case 2: hash = ((hash << 5) + hash) + *p++; /* fallthrough */
|
case 2: hash = ((hash << 5) + hash) + *p++; _Py_FALLTHROUGH;
|
||||||
case 1: hash = ((hash << 5) + hash) + *p++; break;
|
case 1: hash = ((hash << 5) + hash) + *p++; break;
|
||||||
default:
|
default:
|
||||||
Py_UNREACHABLE();
|
Py_UNREACHABLE();
|
||||||
|
@ -391,13 +391,13 @@ siphash13(uint64_t k0, uint64_t k1, const void *src, Py_ssize_t src_sz) {
|
||||||
t = 0;
|
t = 0;
|
||||||
pt = (uint8_t *)&t;
|
pt = (uint8_t *)&t;
|
||||||
switch (src_sz) {
|
switch (src_sz) {
|
||||||
case 7: pt[6] = in[6]; /* fall through */
|
case 7: pt[6] = in[6]; _Py_FALLTHROUGH;
|
||||||
case 6: pt[5] = in[5]; /* fall through */
|
case 6: pt[5] = in[5]; _Py_FALLTHROUGH;
|
||||||
case 5: pt[4] = in[4]; /* fall through */
|
case 5: pt[4] = in[4]; _Py_FALLTHROUGH;
|
||||||
case 4: memcpy(pt, in, sizeof(uint32_t)); break;
|
case 4: memcpy(pt, in, sizeof(uint32_t)); break;
|
||||||
case 3: pt[2] = in[2]; /* fall through */
|
case 3: pt[2] = in[2]; _Py_FALLTHROUGH;
|
||||||
case 2: pt[1] = in[1]; /* fall through */
|
case 2: pt[1] = in[1]; _Py_FALLTHROUGH;
|
||||||
case 1: pt[0] = in[0]; /* fall through */
|
case 1: pt[0] = in[0]; break;
|
||||||
}
|
}
|
||||||
b |= _le64toh(t);
|
b |= _le64toh(t);
|
||||||
|
|
||||||
|
@ -442,13 +442,13 @@ siphash24(uint64_t k0, uint64_t k1, const void *src, Py_ssize_t src_sz) {
|
||||||
t = 0;
|
t = 0;
|
||||||
pt = (uint8_t *)&t;
|
pt = (uint8_t *)&t;
|
||||||
switch (src_sz) {
|
switch (src_sz) {
|
||||||
case 7: pt[6] = in[6]; /* fall through */
|
case 7: pt[6] = in[6]; _Py_FALLTHROUGH;
|
||||||
case 6: pt[5] = in[5]; /* fall through */
|
case 6: pt[5] = in[5]; _Py_FALLTHROUGH;
|
||||||
case 5: pt[4] = in[4]; /* fall through */
|
case 5: pt[4] = in[4]; _Py_FALLTHROUGH;
|
||||||
case 4: memcpy(pt, in, sizeof(uint32_t)); break;
|
case 4: memcpy(pt, in, sizeof(uint32_t)); break;
|
||||||
case 3: pt[2] = in[2]; /* fall through */
|
case 3: pt[2] = in[2]; _Py_FALLTHROUGH;
|
||||||
case 2: pt[1] = in[1]; /* fall through */
|
case 2: pt[1] = in[1]; _Py_FALLTHROUGH;
|
||||||
case 1: pt[0] = in[0]; /* fall through */
|
case 1: pt[0] = in[0]; break;
|
||||||
}
|
}
|
||||||
b |= _le64toh(t);
|
b |= _le64toh(t);
|
||||||
|
|
||||||
|
|
|
@ -1234,7 +1234,7 @@ char * PyOS_double_to_string(double val,
|
||||||
case 'E':
|
case 'E':
|
||||||
float_strings = uc_float_strings;
|
float_strings = uc_float_strings;
|
||||||
format_code = 'e';
|
format_code = 'e';
|
||||||
/* Fall through. */
|
_Py_FALLTHROUGH;
|
||||||
case 'e':
|
case 'e':
|
||||||
mode = 2;
|
mode = 2;
|
||||||
precision++;
|
precision++;
|
||||||
|
@ -1244,7 +1244,7 @@ char * PyOS_double_to_string(double val,
|
||||||
case 'F':
|
case 'F':
|
||||||
float_strings = uc_float_strings;
|
float_strings = uc_float_strings;
|
||||||
format_code = 'f';
|
format_code = 'f';
|
||||||
/* Fall through. */
|
_Py_FALLTHROUGH;
|
||||||
case 'f':
|
case 'f':
|
||||||
mode = 3;
|
mode = 3;
|
||||||
break;
|
break;
|
||||||
|
@ -1253,7 +1253,7 @@ char * PyOS_double_to_string(double val,
|
||||||
case 'G':
|
case 'G':
|
||||||
float_strings = uc_float_strings;
|
float_strings = uc_float_strings;
|
||||||
format_code = 'g';
|
format_code = 'g';
|
||||||
/* Fall through. */
|
_Py_FALLTHROUGH;
|
||||||
case 'g':
|
case 'g':
|
||||||
mode = 2;
|
mode = 2;
|
||||||
/* precision 0 makes no sense for 'g' format; interpret as 1 */
|
/* precision 0 makes no sense for 'g' format; interpret as 1 */
|
||||||
|
|
Loading…
Reference in New Issue