array size could be expressions with known C compile-time values
authorLisandro Dalcin <dalcinl@gmail.com>
Fri, 14 Nov 2008 23:48:45 +0000 (20:48 -0300)
committerLisandro Dalcin <dalcinl@gmail.com>
Fri, 14 Nov 2008 23:48:45 +0000 (20:48 -0300)
Cython/Compiler/PyrexTypes.py
tests/run/carrays.pyx

index 281cf0ad913096958ac941c690f7633c9c589fe0..70330959b791d365cb3d93b59f44cce11705bed3 100644 (file)
@@ -616,7 +616,6 @@ class CArrayType(CType):
     is_array = 1
     
     def __init__(self, base_type, size):
-        assert size is None or isinstance(size, int), repr(size)
         self.base_type = base_type
         self.size = size
         if base_type is c_char_type:
index 3a7e453796f9c75cc86df69b61503e8457f285e4..ca6fd0729c71b9fb68b4c6a4695853132474b53e 100644 (file)
@@ -1,9 +1,13 @@
 __doc__ = """
->>> test()
+>>> test1()
 2
+>>> test2()
+0
+>>> test3()
+(2, 3)
 """
 
-def test():
+def test1():
     cdef int x[2][2]
     x[0][0] = 1
     x[0][1] = 2
@@ -13,3 +17,18 @@ def test():
 
 cdef int* f(int x[2][2]):
     return x[0]
+
+
+def test2():
+    cdef int a1[5]
+    cdef int a2[2+3]
+    return sizeof(a1) - sizeof(a2)
+
+cdef enum:
+    MY_SIZE_A = 2
+    MY_SIZE_B = 3
+
+def test3():
+    cdef int a[MY_SIZE_A]
+    cdef int b[MY_SIZE_B]
+    return sizeof(a)/sizeof(int), sizeof(b)/sizeof(int)