Commit 67d948aa authored by Stefan Behnel's avatar Stefan Behnel

avoid generating some unreachable code on function exit

parent fc2de434
...@@ -1799,19 +1799,21 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1799,19 +1799,21 @@ class FuncDefNode(StatNode, BlockNode):
code.putln("/* function exit code */") code.putln("/* function exit code */")
# ----- Default return value # ----- Default return value
if self.return_type.is_pyobject: if not self.body.is_terminator:
#if self.return_type.is_extension_type: if self.return_type.is_pyobject:
# lhs = "(PyObject *)%s" % Naming.retval_cname #if self.return_type.is_extension_type:
#else: # lhs = "(PyObject *)%s" % Naming.retval_cname
lhs = Naming.retval_cname #else:
code.put_init_to_py_none(lhs, self.return_type) lhs = Naming.retval_cname
else: code.put_init_to_py_none(lhs, self.return_type)
val = self.return_type.default_value else:
if val: val = self.return_type.default_value
code.putln("%s = %s;" % (Naming.retval_cname, val)) if val:
code.putln("%s = %s;" % (Naming.retval_cname, val))
# ----- Error cleanup # ----- Error cleanup
if code.error_label in code.labels_used: if code.error_label in code.labels_used:
code.put_goto(code.return_label) if not self.body.is_terminator:
code.put_goto(code.return_label)
code.put_label(code.error_label) code.put_label(code.error_label)
for cname, type in code.funcstate.all_managed_temps(): for cname, type in code.funcstate.all_managed_temps():
code.put_xdecref(cname, type, have_gil=not lenv.nogil) code.put_xdecref(cname, type, have_gil=not lenv.nogil)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment