[pypy-commit] cffi default: Test and fix: don't allow 'void' as the type of a function argument.
arigo
noreply at buildbot.pypy.org
Wed Aug 22 19:50:15 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r872:b3678ddd1d27
Date: 2012-08-22 19:50 +0200
http://bitbucket.org/cffi/cffi/changeset/b3678ddd1d27/
Log: Test and fix: don't allow 'void' as the type of a function argument.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3184,7 +3184,7 @@
else if (ct->ct_flags & (CT_POINTER|CT_ARRAY|CT_FUNCTIONPTR)) {
return &ffi_type_pointer;
}
- else if (ct->ct_flags & CT_VOID) {
+ else if ((ct->ct_flags & CT_VOID) && is_result_type) {
return &ffi_type_void;
}
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -773,6 +773,11 @@
BFunc = new_function_type((BInt, BInt), BVoid, False)
assert repr(BFunc) == "<ctype 'void(*)(int, int)'>"
+def test_function_void_arg():
+ BVoid = new_void_type()
+ BInt = new_primitive_type("int")
+ py.test.raises(TypeError, new_function_type, (BVoid,), BInt, False)
+
def test_call_function_0():
BSignedChar = new_primitive_type("signed char")
BFunc0 = new_function_type((BSignedChar, BSignedChar), BSignedChar, False)
More information about the pypy-commit
mailing list