Commit 258a185b authored by Robert Bradshaw's avatar Robert Bradshaw

Fix cpp exception catching.

parent 72b07822
...@@ -547,17 +547,23 @@ class CFuncDeclaratorNode(CDeclaratorNode): ...@@ -547,17 +547,23 @@ class CFuncDeclaratorNode(CDeclaratorNode):
if self.exception_value: if self.exception_value:
self.exception_value.analyse_const_expression(env) self.exception_value.analyse_const_expression(env)
if self.exception_check == '+': if self.exception_check == '+':
self.exception_value.analyse_types(env)
exc_val_type = self.exception_value.type exc_val_type = self.exception_value.type
if not exc_val_type.is_error and \ if not exc_val_type.is_error and \
not exc_val_type.is_pyobject and \ not exc_val_type.is_pyobject and \
not (exc_val_type.is_cfunction and not exc_val_type.return_type.is_pyobject and len(exc_val_type.args)==0): not (exc_val_type.is_cfunction and not exc_val_type.return_type.is_pyobject and len(exc_val_type.args)==0):
error(self.exception_value.pos, error(self.exception_value.pos,
"Exception value must be a Python exception or cdef function with no arguments.") "Exception value must be a Python exception or cdef function with no arguments.")
exc_val = self.exception_value
else: else:
exc_val = self.exception_value.get_constant_c_result_code() if self.exception_value.analyse_const_expression(env):
if not return_type.assignable_from(self.exception_value.type): exc_val = self.exception_value.get_constant_c_result_code()
error(self.exception_value.pos, if exc_val is None:
"Exception value incompatible with function return type") raise InternalError("get_constant_c_result_code not implemented for %s" %
self.exception_value.__class__.__name__)
if not return_type.assignable_from(self.exception_value.type):
error(self.exception_value.pos,
"Exception value incompatible with function return type")
exc_check = self.exception_check exc_check = self.exception_check
if return_type.is_array: if return_type.is_array:
error(self.pos, error(self.pos,
......
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