Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r59119:a385eb053904
Date: 2012-11-28 16:04 -0800
http://bitbucket.org/pypy/pypy/changeset/a385eb053904/

Log:    A fix for a compiler warning, and a test. The test did not fail
        before; but it still works, and you can check that it no longer
        gives compiler warnings...

diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py
--- a/pypy/translator/c/funcgen.py
+++ b/pypy/translator/c/funcgen.py
@@ -494,7 +494,8 @@
 
     def OP_GETSUBSTRUCT(self, op):
         RESULT = self.lltypemap(op.result).TO
-        if isinstance(RESULT, FixedSizeArray):
+        if (isinstance(RESULT, FixedSizeArray) or
+                (isinstance(RESULT, Array) and barebonearray(RESULT))):
             return self.OP_GETFIELD(op, ampersand='')
         else:
             return self.OP_GETFIELD(op, ampersand='&')
diff --git a/pypy/translator/c/test/test_lltyped.py 
b/pypy/translator/c/test/test_lltyped.py
--- a/pypy/translator/c/test/test_lltyped.py
+++ b/pypy/translator/c/test/test_lltyped.py
@@ -907,3 +907,15 @@
             return rstring_to_float(s)
         fn = self.getcompiled(llf, [int])
         assert fn(0) == 42.3
+
+    def test_raw_array_field(self):
+        from pypy.rpython.lltypesystem import rffi
+        S = Struct('S', ('array', rffi.CArray(Signed)))
+        def llf(i):
+            s = malloc(S, i, flavor='raw')
+            s.array[i-2] = 42
+            x = s.array[i-2]
+            free(s, flavor='raw')
+            return x
+        fn = self.getcompiled(llf, [int])
+        assert fn(5) == 42
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to