[pypy-svn] r32387 - in pypy/branch/kill-keepalives/pypy/translator/c: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Sep 16 14:44:26 CEST 2006
Author: arigo
Date: Sat Sep 16 14:44:25 2006
New Revision: 32387
Modified:
pypy/branch/kill-keepalives/pypy/translator/c/funcgen.py
pypy/branch/kill-keepalives/pypy/translator/c/test/test_lltyped.py
Log:
Fix bad C code that produced a gcc warning. Very very corner-casish.
Modified: pypy/branch/kill-keepalives/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/branch/kill-keepalives/pypy/translator/c/funcgen.py (original)
+++ pypy/branch/kill-keepalives/pypy/translator/c/funcgen.py Sat Sep 16 14:44:25 2006
@@ -522,9 +522,10 @@
items = self.expr(op.args[0])
if not isinstance(ARRAY, FixedSizeArray):
items += '->items'
- return '%s = %s + %s;' % (self.expr(op.result),
- items,
- self.expr(op.args[1]))
+ result = '%s + %s' % (items, self.expr(op.args[1]))
+ if isinstance(ARRAY.OF, FixedSizeArray): # more C blaming here
+ result = '*(%s)' % (result,)
+ return '%s = %s;' % (self.expr(op.result), result)
def OP_PTR_NONZERO(self, op):
return '%s = (%s != NULL);' % (self.expr(op.result),
Modified: pypy/branch/kill-keepalives/pypy/translator/c/test/test_lltyped.py
==============================================================================
--- pypy/branch/kill-keepalives/pypy/translator/c/test/test_lltyped.py (original)
+++ pypy/branch/kill-keepalives/pypy/translator/c/test/test_lltyped.py Sat Sep 16 14:44:25 2006
@@ -48,7 +48,6 @@
assert a42[5][6] == -6
return len(a42)*100 + len(a42[4])
fn = self.getcompiled(llf)
- res = fn()
assert fn() == 607
def test_recursivearray(self):
@@ -63,6 +62,19 @@
fn = self.getcompiled(llf)
fn()
+ def test_array_of_array(self):
+ C = FixedSizeArray(Signed, 7)
+ B = Array(C)
+ A = FixedSizeArray(C, 6)
+ b = malloc(B, 5, immortal=True)
+ b[3][4] = 999
+ a = malloc(A, immortal=True)
+ a[2][5] = 888000
+ def llf():
+ return b[3][4] + a[2][5]
+ fn = self.getcompiled(llf)
+ assert fn() == 888999
+
def test_prebuilt_array(self):
A = FixedSizeArray(Signed, 5)
a = malloc(A, immortal=True)
@@ -128,10 +140,9 @@
assert res == 123
def test_more_prebuilt_arrays(self):
- py.test.skip("not allowed any more")
A = FixedSizeArray(Struct('s1', ('x', Signed)), 5)
- S = GcStruct('s', ('a1', Ptr(A)), ('a2', A))
- s = malloc(S, zero=True)
+ S = Struct('s', ('a1', Ptr(A)), ('a2', A))
+ s = malloc(S, zero=True, immortal=True)
s.a1 = malloc(A, immortal=True)
s.a1[2].x = 50
s.a2[2].x = 60
More information about the Pypy-commit
mailing list