mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-42246: Don't forget the entry block when ensuring that all exits have a line number (GH-23636)
Don't forget the entry block when ensuring that all exits have a line number.
This commit is contained in:
parent
f24b8101a0
commit
eaccc12aa9
4 changed files with 28 additions and 4 deletions
|
|
@ -6514,6 +6514,7 @@ is_exit_without_lineno(basicblock *b) {
|
|||
static int
|
||||
ensure_exits_have_lineno(struct compiler *c)
|
||||
{
|
||||
basicblock *entry = NULL;
|
||||
/* Copy all exit blocks without line number that are targets of a jump.
|
||||
*/
|
||||
for (basicblock *b = c->u->u_blocks; b != NULL; b = b->b_list) {
|
||||
|
|
@ -6535,6 +6536,11 @@ ensure_exits_have_lineno(struct compiler *c)
|
|||
b->b_instr[b->b_iused-1].i_target = new_target;
|
||||
}
|
||||
}
|
||||
entry = b;
|
||||
}
|
||||
assert(entry != NULL);
|
||||
if (is_exit_without_lineno(entry)) {
|
||||
entry->b_instr[0].i_lineno = c->u->u_firstlineno;
|
||||
}
|
||||
/* Any remaining reachable exit blocks without line number can only be reached by
|
||||
* fall through, and thus can only have a single predecessor */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue