Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r2363:e6500be6fdfb Date: 2015-11-02 16:17 +0100 http://bitbucket.org/cffi/cffi/changeset/e6500be6fdfb/
Log: Fix the error we get for 'int f(unknown_type);' diff --git a/cffi/cparser.py b/cffi/cparser.py --- a/cffi/cparser.py +++ b/cffi/cparser.py @@ -456,6 +456,13 @@ def _parse_function_type(self, typenode, funcname=None): params = list(getattr(typenode.args, 'params', [])) + for i, arg in enumerate(params): + if not hasattr(arg, 'type'): + raise api.CDefError("%s arg %d: unknown type '%s'" + " (if you meant to use the old C syntax of giving" + " untyped arguments, it is not supported)" + % (funcname or 'in expression', i + 1, + getattr(arg, 'name', '?'))) ellipsis = ( len(params) > 0 and isinstance(params[-1].type, pycparser.c_ast.TypeDecl) and diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py --- a/testing/cffi0/test_parsing.py +++ b/testing/cffi0/test_parsing.py @@ -272,6 +272,13 @@ ffi = FFI() ffi.cdef("typedef _Bool bool; void f(bool);") +def test_unknown_argument_type(): + ffi = FFI() + e = py.test.raises(CDefError, ffi.cdef, "void f(foobarbazzz);") + assert str(e.value) == ("f arg 1: unknown type 'foobarbazzz' (if you meant" + " to use the old C syntax of giving untyped" + " arguments, it is not supported)") + def test_void_renamed_as_only_arg(): ffi = FFI() ffi.cdef("typedef void void_t1;" _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit