Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,13 @@ extern "C" {
// case 2: code; break;
// }
//
// __attribute__((fallthrough)) was introduced in GCC 7.
#if _Py__has_attribute(fallthrough)
// __attribute__((fallthrough)) was introduced in GCC 7 and Clang 10 /
// Apple Clang 12.0. Earlier Clang versions support only the C++11
// style fallthrough attribute, not the GCC extension syntax used here,
// and __has_attribute(fallthrough) evaluates to 1.
#if _Py__has_attribute(fallthrough) && (!defined(__clang__) || \
(!defined(__apple_build_version__) && __clang_major__ >= 10) || \
(defined(__apple_build_version__) && __clang_major__ >= 12))
# define _Py_FALLTHROUGH __attribute__((fallthrough))
#else
# define _Py_FALLTHROUGH do { } while (0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compile errors with Clang 9 and older due to lack of ``__attribute__((fallthrough))`` support.
Loading