Skip to content

Commit 1229037

Browse files
committed
Add a couple of asserts for NEXT_LOCATION
1 parent ab6fa4c commit 1229037

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Python/assemble.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,15 @@ assemble_location_info(struct assembler *a, instr_sequence *instrs,
343343
a->a_lineno = firstlineno;
344344
location loc = NO_LOCATION;
345345
int size = 0;
346+
// The last location should not be NEXT_LOCATION, but don't crash non-debug builds
346347
if (same_location(instrs->s_instrs[instrs->s_used-1].i_loc, NEXT_LOCATION)) {
348+
assert(0 && "last instruction has NEXT_LOCATION");
347349
instrs->s_instrs[instrs->s_used-1].i_loc = NO_LOCATION;
348350
}
349351
for (int i = instrs->s_used-1; i > 0; i--) {
350352
instruction *instr = &instrs->s_instrs[i];
351353
if (same_location(instr[-1].i_loc, NEXT_LOCATION)) {
354+
assert(!IS_TERMINATOR_OPCODE(instr[-1].i_opcode));
352355
instr[-1].i_loc = instr->i_loc;
353356
}
354357
}

0 commit comments

Comments
 (0)