[3.14] gh-140513: Fail to compile if _Py_TAIL_CALL_INTERP is set but preserve_none and musttail do not exist (GH-140548) (#140923)

gh-140513: Fail to compile if `_Py_TAIL_CALL_INTERP` is set but `preserve_none` and `musttail` do not exist. (GH-140548)


(cherry picked from commit 2f60b8f02f)

Co-authored-by: Krishna Chaitanya <141550576+XChaitanyaX@users.noreply.github.com>
This commit is contained in:
Chris Eibl 2025-11-04 21:43:18 +01:00 committed by GitHub
parent d82d340096
commit f0eb7d4c9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -79,6 +79,14 @@
#endif
#if Py_TAIL_CALL_INTERP
# if defined(__clang__) || defined(__GNUC__)
# if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)
# error "This compiler does not have support for efficient tail calling."
# endif
# elif defined(_MSC_VER)
# error "Tail calling not supported for MSVC."
# endif
// Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
# define Py_MUSTTAIL [[clang::musttail]]
# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))