mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-126211: Exclude preprocessor directives from statements containing escaping calls (#126213)
The cases generator inserts code to save and restore the stack pointer around statements that contain escaping calls. To find the beginning of such statements, we would walk backwards from the escaping call until we encountered a token that was treated as a statement terminator. This set of terminators should include preprocessor directives.
This commit is contained in:
parent
32e07fd377
commit
821759d631
2 changed files with 34 additions and 1 deletions
|
@ -1429,6 +1429,39 @@ class TestGeneratedCases(unittest.TestCase):
|
|||
with self.assertRaisesRegex(SyntaxError, "All instructions containing a uop"):
|
||||
self.run_cases_test(input, output)
|
||||
|
||||
def test_escaping_call_next_to_cmacro(self):
|
||||
input = """
|
||||
inst(OP, (--)) {
|
||||
#ifdef Py_GIL_DISABLED
|
||||
escaping_call();
|
||||
#else
|
||||
another_escaping_call();
|
||||
#endif
|
||||
yet_another_escaping_call();
|
||||
}
|
||||
"""
|
||||
output = """
|
||||
TARGET(OP) {
|
||||
frame->instr_ptr = next_instr;
|
||||
next_instr += 1;
|
||||
INSTRUCTION_STATS(OP);
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
escaping_call();
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#else
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
another_escaping_call();
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#endif
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
yet_another_escaping_call();
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
self.run_cases_test(input, output)
|
||||
|
||||
|
||||
class TestGeneratedAbstractCases(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue