Commit 58e7e5de authored by Robert Bradshaw's avatar Robert Bradshaw

Allow unary negation and complement for enum types.

parent 6af313c9
...@@ -5501,6 +5501,8 @@ class UnaryMinusNode(UnopNode): ...@@ -5501,6 +5501,8 @@ class UnaryMinusNode(UnopNode):
if self.operand.type.is_numeric: if self.operand.type.is_numeric:
self.type = PyrexTypes.widest_numeric_type( self.type = PyrexTypes.widest_numeric_type(
self.operand.type, PyrexTypes.c_int_type) self.operand.type, PyrexTypes.c_int_type)
elif self.operand.type.is_enum:
self.type = PyrexTypes.c_int_type
else: else:
self.type_error() self.type_error()
if self.type.is_complex: if self.type.is_complex:
...@@ -5527,6 +5529,8 @@ class TildeNode(UnopNode): ...@@ -5527,6 +5529,8 @@ class TildeNode(UnopNode):
if self.operand.type.is_int: if self.operand.type.is_int:
self.type = PyrexTypes.widest_numeric_type( self.type = PyrexTypes.widest_numeric_type(
self.operand.type, PyrexTypes.c_int_type) self.operand.type, PyrexTypes.c_int_type)
elif self.operand.type.is_enum:
self.type = PyrexTypes.c_int_type
else: else:
self.type_error() self.type_error()
......
...@@ -25,5 +25,7 @@ cdef void f(): ...@@ -25,5 +25,7 @@ cdef void f():
# f = j ** e # Cython prohibits this # f = j ** e # Cython prohibits this
i = e + g i = e + g
f = h f = h
i = ~a
i = -a
f() f()
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