Commit a89bf856 authored by Stefan Behnel's avatar Stefan Behnel

keep longness when folding negative integer constants

--HG--
extra : transplant_source : %CC%EC%23%19%11%1A%22%FB%5C-%18%AD%0D%FC%24L%BD%81%91%FF
parent 6ced0d1e
......@@ -7290,7 +7290,8 @@ def unop_node(pos, operator, operand):
# Construct unnop node of appropriate class for
# given operator.
if isinstance(operand, IntNode) and operator == '-':
return IntNode(pos = operand.pos, value = str(-Utils.str_to_number(operand.value)))
return IntNode(pos = operand.pos, value = str(-Utils.str_to_number(operand.value)),
longness=operand.longness, unsigned=operand.unsigned)
elif isinstance(operand, UnopNode) and operand.operator == operator in '+-':
warning(pos, "Python has no increment/decrement operator: %s%sx == %s(%sx) == x" % ((operator,)*4), 5)
return unop_node_classes[operator](pos,
......
__doc__ = u"""
>>> c_longs()
(1, 1L, -1L, 18446744073709551615L)
>>> negative_c_longs()
(-1, -9223285636854775809L)
>>> py_longs()
(1, 1L, 100000000000000000000000000000000L, -100000000000000000000000000000000L)
......@@ -18,14 +20,28 @@ import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u'L', u'')
@cython.test_assert_path_exists(
'//IntNode[@longness = "LL"]',
'//IntNode[@longness = "L"]',
)
@cython.test_fail_if_path_exists('//IntNode[@longness = ""]')
def c_longs():
cdef long a = 1L
cdef unsigned long ua = 1UL
cdef long long aa = 0xFFFFFFFFFFFFFFFFLL
cdef unsigned long long uaa = 0xFFFFFFFFFFFFFFFFULL
return a, ua, aa, uaa
@cython.test_assert_path_exists(
'//IntNode[@longness = "LL"]',
'//IntNode[@longness = "L"]',
)
@cython.test_fail_if_path_exists('//IntNode[@longness = ""]')
def negative_c_longs():
cdef long a = -1L
cdef long long aa = -9223285636854775809LL
return a, aa
def py_longs():
return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000
......
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