[pypy-commit] pypy gc-del: An extra test.

arigo noreply at buildbot.pypy.org
Mon Mar 25 23:25:25 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: gc-del
Changeset: r62760:b56873d13d98
Date: 2013-03-25 21:55 +0100
http://bitbucket.org/pypy/pypy/changeset/b56873d13d98/

Log:	An extra test.

diff --git a/rpython/translator/backendopt/destructor.py b/rpython/translator/backendopt/destructor.py
--- a/rpython/translator/backendopt/destructor.py
+++ b/rpython/translator/backendopt/destructor.py
@@ -19,9 +19,11 @@
                      'raw_free']
 
     def check_destructor(self, graph):
+        self.unsupported_op = None
         result = self.analyze_direct_call(graph)
         if result is self.top_result():
-            raise DestructorError(DestructorError.__doc__, graph)
+            raise DestructorError(DestructorError.__doc__, graph,
+                                  self.unsupported_op)
 
     def analyze_simple_operation(self, op, graphinfo):
         if op.opname in self.ok_operations:
@@ -39,4 +41,5 @@
             if not isinstance(TP, lltype.Ptr) or TP.TO._gckind == 'raw':
                 # primitive type
                 return self.bottom_result()
+        self.unsupported_op = op
         return self.top_result()
diff --git a/rpython/translator/backendopt/test/test_destructor.py b/rpython/translator/backendopt/test/test_destructor.py
--- a/rpython/translator/backendopt/test/test_destructor.py
+++ b/rpython/translator/backendopt/test/test_destructor.py
@@ -108,6 +108,25 @@
         r = self.analyze(g, [], f, backendopt=True)
         assert not r
 
+    def test_c_call_2(self):
+        X = lltype.Ptr(lltype.Struct('X'))
+        x = rffi.llexternal('x', [X], lltype.Signed, threadsafe=True)
+        class C(object):
+            lib = rffi.cast(X, -1)
+
+        def g():
+            c = C()
+            c.lib = rffi.cast(X, -2)
+            f(c)
+
+        def f(c):
+            if c.lib != rffi.cast(X, -1):
+                x(c.lib)
+                c.lib = rffi.cast(X, -1)
+
+        r = self.analyze(g, [], f, backendopt=True)
+        assert not r
+
     def test_chain(self):
         class B(object):
             def __init__(self):


More information about the pypy-commit mailing list