Commit ea9ca9d4 authored by Stefan Behnel's avatar Stefan Behnel

fix compiler crash on bad code (complex % x) and move directive handling in...

fix compiler crash on bad code (complex % x) and move directive handling in ModNode to analysis phase
parent bf2a6c4a
......@@ -9029,16 +9029,24 @@ class ModNode(DivNode):
else:
return "float divmod()"
def generate_evaluation_code(self, code):
def analyse_operation(self, env):
DivNode.analyse_operation(self, env)
if not self.type.is_pyobject:
if self.cdivision is None:
self.cdivision = code.globalstate.directives['cdivision'] or not self.type.signed
if not self.cdivision:
if self.type.is_int:
code.globalstate.use_utility_code(mod_int_utility_code.specialize(self.type))
else:
code.globalstate.use_utility_code(
mod_float_utility_code.specialize(self.type, math_h_modifier=self.type.math_h_modifier))
self.cdivision = env.directives['cdivision'] or not self.type.signed
if not self.cdivision and not self.type.is_int and not self.type.is_float:
error(self.pos, "mod operator not supported for type '%s'" % self.type)
def generate_evaluation_code(self, code):
if not self.type.is_pyobject and not self.cdivision:
if self.type.is_int:
code.globalstate.use_utility_code(
mod_int_utility_code.specialize(self.type))
else: # float
code.globalstate.use_utility_code(
mod_float_utility_code.specialize(
self.type, math_h_modifier=self.type.math_h_modifier))
# note: skipping over DivNode here
NumBinopNode.generate_evaluation_code(self, code)
self.generate_div_warning_code(code)
......
# mode: error
def mod_complex():
x = (1.1+2.0j) % 4
return x
_ERRORS = """
4:19: mod operator not supported for type 'double complex'
"""
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