More variable used problems in buffers fixed
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 1 Aug 2008 22:01:53 +0000 (00:01 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 1 Aug 2008 22:01:53 +0000 (00:01 +0200)
Cython/Compiler/Buffer.py
Cython/Compiler/ExprNodes.py
tests/run/bufaccess.pyx

index b77b594d675564ffc6a79bef3d8992c8251b2589..4e9df45968cf47318e7021bc740f59bb3c1b680b 100644 (file)
@@ -119,7 +119,8 @@ def used_buffer_aux_vars(entry):
     buffer_aux.buffer_info_var.used = True
     for s in buffer_aux.shapevars: s.used = True
     for s in buffer_aux.stridevars: s.used = True
-    for s in buffer_aux.suboffsetvars: s.used = True
+    if buffer_aux.suboffsetvars:
+        for s in buffer_aux.suboffsetvars: s.used = True
 
 def put_unpack_buffer_aux_into_scope(buffer_aux, mode, code):
     # Generate code to copy the needed struct info into local
index 6fb5744d7598c7e9734e17739f03eda2bf39d8ba..db2e323b411d6bd98475dfeb102e4ded42ccf3de 100644 (file)
@@ -885,9 +885,6 @@ class NameNode(AtomicExprNode):
             self.type = PyrexTypes.error_type
         self.entry.used = 1
         if self.entry.type.is_buffer:
-            # Have an rhs temp just in case. All rhs I could
-            # think of had a single symbol result_code but better
-            # safe than sorry. Feel free to change this.
             import Buffer
             Buffer.used_buffer_aux_vars(self.entry)
                 
@@ -964,6 +961,9 @@ class NameNode(AtomicExprNode):
         entry = self.entry
         if entry:
             entry.used = 1
+            if entry.type.is_buffer:
+                import Buffer
+                Buffer.used_buffer_aux_vars(entry)
             if entry.utility_code:
                 env.use_utility_code(entry.utility_code)
         
index d61ae74f08730d4d43a436d7aab5572befbf3c0c..a40a937fc06e3e1738eb48d9790097f73f811ef2 100644 (file)
@@ -34,14 +34,18 @@ def testcas(a):
 # Buffer acquire and release tests
 #
 
-@testcase
 def nousage():
     """
-    >>> True
-    True
+    The challenge here is just compilation.
+    """
+    cdef object[int, 2] buf
+
+def printbuf():
+    """
+    Just compilation.
     """
     cdef object[int, 2] buf
-    # this used not to compile
+    print buf
 
 @testcase
 def acquire_release(o1, o2):