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

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
This commit is contained in:
Krishna Chaitanya
2025-11-01 22:11:23 +05:30
committed by GitHub
parent b1554146c2
commit 2f60b8f02f
2 changed files with 10 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
Generate a clear compilation error when ``_Py_TAIL_CALL_INTERP`` is enabled but
either ``preserve_none`` or ``musttail`` is not supported.

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) && (_MSC_VER < 1950)
# error "You need at least VS 2026 / PlatformToolset v145 for tail calling."
# 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))