Fix types of marked integer literals.
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 27 May 2010 04:21:16 +0000 (21:21 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 27 May 2010 04:21:16 +0000 (21:21 -0700)
Cython/Compiler/ExprNodes.py
tests/run/int_literals.pyx

index 413a51f2e949fc8bc267e225f55337522d41ca73..ad266fd4471655f42ef68fe73e7d2954b3dabb98 100755 (executable)
@@ -787,7 +787,12 @@ class IntNode(ConstNode):
 
     unsigned = ""
     longness = ""
-    type = PyrexTypes.c_long_type
+
+    def __init__(self, pos, **kwds):
+        ExprNode.__init__(self, pos, **kwds)
+        rank = max(1, len(self.longness))
+        sign = not self.unsigned
+        self.type = PyrexTypes.modifiers_and_name_to_type[sign, rank, "int"]
 
     def coerce_to(self, dst_type, env):
         if self.type is dst_type:
index 6dca2dd3ed4c93e132936e8e4548d7258827fb5a..2e38b0cf5835ff4dff10684003addcc55d35c78d 100644 (file)
@@ -6,6 +6,7 @@ __doc__ = u"""
 """
 
 import sys
+from cython cimport typeof
 
 if sys.version_info[0] >= 3:
     __doc__ = __doc__.replace(u'L', u'')
@@ -35,3 +36,20 @@ def large_literal():
         return 0xFFFFFFFFFFFF
     else:
         return 0xFFFFFFF
+
+def c_long_types():
+    """
+    >>> c_long_types()
+    long
+    long
+    long long
+    unsigned long
+    unsigned long
+    unsigned long long
+    """
+    print typeof(1)
+    print typeof(1L)
+    print typeof(1LL)
+    print typeof(1U)
+    print typeof(1UL)
+    print typeof(1ULL)