mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
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
29 changed files with 131 additions and 104 deletions
|
@ -5073,7 +5073,7 @@ unicode_decode_utf8_impl(_PyUnicodeWriter *writer,
|
|||
/* Truncated surrogate code in range D800-DFFF */
|
||||
goto End;
|
||||
}
|
||||
/* fall through */
|
||||
_Py_FALLTHROUGH;
|
||||
case 3:
|
||||
case 4:
|
||||
errmsg = "invalid continuation byte";
|
||||
|
@ -7108,7 +7108,7 @@ unicode_encode_ucs1(PyObject *unicode,
|
|||
case _Py_ERROR_REPLACE:
|
||||
memset(str, '?', collend - collstart);
|
||||
str += (collend - collstart);
|
||||
/* fall through */
|
||||
_Py_FALLTHROUGH;
|
||||
case _Py_ERROR_IGNORE:
|
||||
pos = collend;
|
||||
break;
|
||||
|
@ -7147,7 +7147,7 @@ unicode_encode_ucs1(PyObject *unicode,
|
|||
break;
|
||||
collstart = pos;
|
||||
assert(collstart != collend);
|
||||
/* fall through */
|
||||
_Py_FALLTHROUGH;
|
||||
|
||||
default:
|
||||
rep = unicode_encode_call_errorhandler(errors, &error_handler_obj,
|
||||
|
@ -8699,7 +8699,7 @@ charmap_encoding_error(
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
/* fall through */
|
||||
_Py_FALLTHROUGH;
|
||||
case _Py_ERROR_IGNORE:
|
||||
*inpos = collendpos;
|
||||
break;
|
||||
|
@ -15673,7 +15673,7 @@ _PyUnicode_ClearInterned(PyInterpreterState *interp)
|
|||
#endif
|
||||
break;
|
||||
case SSTATE_NOT_INTERNED:
|
||||
/* fall through */
|
||||
_Py_FALLTHROUGH;
|
||||
default:
|
||||
Py_UNREACHABLE();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue