Skip to content
Snippets Groups Projects
Commit 57995c0051cf authored by Stefan Behnel's avatar Stefan Behnel
Browse files

Validate that all temps were correctly released at the end of a function.

parent ad731131481e
No related branches found
No related tags found
No related merge requests found
......@@ -735,6 +735,20 @@
self.should_declare_error_indicator = False
self.uses_error_indicator = False
# safety checks
def validate_exit(self):
# validate that all allocated temps have been freed
if self.temps_allocated:
leftovers = set(self.all_managed_temps()).difference(self.all_free_managed_temps())
if leftovers:
msg = "Temps left over at end of '%s': %s" % (
self.scope.name,
', '.join(map(str, sorted(leftovers, key=operator.itemgetter(0)))),
)
print(msg)
#raise RuntimeError(msg)
# labels
def new_label(self, name=None):
......@@ -1860,6 +1874,7 @@
self.funcstate = FunctionState(self, scope=scope)
def exit_cfunc_scope(self):
self.funcstate.validate_exit()
self.funcstate = None
# constant handling
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment