Skip to content

Commit f0eb7d4

Browse files
[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 2f60b8f) Co-authored-by: Krishna Chaitanya <[email protected]>
1 parent d82d340 commit f0eb7d4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Generate a clear compilation error when ``_Py_TAIL_CALL_INTERP`` is enabled but
2+
either ``preserve_none`` or ``musttail`` is not supported.

Python/ceval_macros.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@
7979
#endif
8080

8181
#if Py_TAIL_CALL_INTERP
82+
# if defined(__clang__) || defined(__GNUC__)
83+
# if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)
84+
# error "This compiler does not have support for efficient tail calling."
85+
# endif
86+
# elif defined(_MSC_VER)
87+
# error "Tail calling not supported for MSVC."
88+
# endif
89+
8290
// Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
8391
# define Py_MUSTTAIL [[clang::musttail]]
8492
# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))

0 commit comments

Comments
 (0)