[pypy-commit] pypy stmgc-c7: Test and fix
arigo
noreply at buildbot.pypy.org
Thu Aug 28 15:12:16 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r73110:e8fa261dce03
Date: 2014-08-28 15:11 +0200
http://bitbucket.org/pypy/pypy/changeset/e8fa261dce03/
Log: Test and fix
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -435,11 +435,14 @@
if isinstance(ARGTYPE, ContainerType):
args[-1] = '*%s' % (args[-1],)
- line = '%s(%s);' % (fnexpr, ', '.join(args))
- if self.lltypemap(v_result) is not Void:
- # skip assignment of 'void' return value
- r = self.expr(v_result)
- line = '%s = %s' % (r, line)
+ if fnexpr == 'NULL':
+ line = 'abort(); /* call to NULL */'
+ else:
+ line = '%s(%s);' % (fnexpr, ', '.join(args))
+ if self.lltypemap(v_result) is not Void:
+ # skip assignment of 'void' return value
+ r = self.expr(v_result)
+ line = '%s = %s' % (r, line)
if targets:
for graph in targets:
if getattr(graph, 'inhibit_tail_call', False):
diff --git a/rpython/translator/c/test/test_lltyped.py b/rpython/translator/c/test/test_lltyped.py
--- a/rpython/translator/c/test/test_lltyped.py
+++ b/rpython/translator/c/test/test_lltyped.py
@@ -956,3 +956,13 @@
fn = self.getcompiled(f, [int])
assert fn(0) == 9
+
+ def test_call_null_funcptr(self):
+ fnptr = nullptr(FuncType([], Void))
+ def f(n):
+ if n > 10:
+ fnptr() # never reached, or so we hope
+ return n
+
+ fn = self.getcompiled(f, [int])
+ assert fn(6) == 6
More information about the pypy-commit
mailing list