Commit 683aa853 authored by Stefan Behnel's avatar Stefan Behnel

fix C compiler warning when checking int overflow for division by enum values...

fix C compiler warning when checking int overflow for division by enum values on 32 bit systems (in case anyone cares...)
parent 6206e1a0
...@@ -9239,10 +9239,14 @@ class DivNode(NumBinopNode): ...@@ -9239,10 +9239,14 @@ class DivNode(NumBinopNode):
code.putln("}") code.putln("}")
if self.type.is_int and self.type.signed and self.operator != '%': if self.type.is_int and self.type.signed and self.operator != '%':
code.globalstate.use_utility_code(division_overflow_test_code) code.globalstate.use_utility_code(division_overflow_test_code)
code.putln("else if (sizeof(%s) == sizeof(long) && unlikely(%s == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(%s))) {" % ( type_of_op2 = self.operand2.type.declaration_code('')
self.type.declaration_code(''), code.putln("else if (sizeof(%s) == sizeof(long)"
self.operand2.result(), " && (!(((%s)-1) > 0)) && unlikely(%s == (%s)-1)"
self.operand1.result())) " && unlikely(UNARY_NEG_WOULD_OVERFLOW(%s))) {" % (
self.type.declaration_code(''),
type_of_op2,
self.operand2.result(), type_of_op2,
self.operand1.result()))
code.put_ensure_gil() code.put_ensure_gil()
code.putln('PyErr_Format(PyExc_OverflowError, "value too large to perform division");') code.putln('PyErr_Format(PyExc_OverflowError, "value too large to perform division");')
code.put_release_ensured_gil() code.put_release_ensured_gil()
......
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