diff options
| author | Armin Rigo <arigo@tunes.org> | 2015-06-15 09:04:20 +0200 |
|---|---|---|
| committer | Armin Rigo <arigo@tunes.org> | 2015-06-15 09:04:20 +0200 |
| commit | 4afd68b39ec91c1923d74aa45b2d9120ef8a5036 (patch) | |
| tree | 7805ec143ef5211ededb5e8dd02b2fcd54ffe76d | |
| parent | d1716f8ee5dd98b1c6d83cd362115940cf3d8c0a (diff) | |
| download | cffi-4afd68b39ec91c1923d74aa45b2d9120ef8a5036.tar.gz | |
Explicitly complain if we find 'typedef int... t;' in a call to verify()
| -rw-r--r-- | cffi/cparser.py | 4 | ||||
| -rw-r--r-- | cffi/verifier.py | 4 | ||||
| -rw-r--r-- | testing/cffi0/test_verify.py | 12 |
3 files changed, 20 insertions, 0 deletions
diff --git a/cffi/cparser.py b/cffi/cparser.py index 5eed5a5..6675b30 100644 --- a/cffi/cparser.py +++ b/cffi/cparser.py @@ -102,6 +102,7 @@ class Parser(object): self._packed = False self._int_constants = {} self._recomplete = [] + self._uses_new_feature = None def _parse(self, csource): csource, macros = _preprocess(csource) @@ -648,4 +649,7 @@ class Parser(object): for t in typenames[:-1]: if t not in ['int', 'short', 'long', 'signed', 'unsigned', 'char']: raise api.FFIError(':%d: bad usage of "..."' % decl.coord.line) + if self._uses_new_feature is None: + self._uses_new_feature = "'typedef %s... %s'" % ( + ' '.join(typenames[:-1]), decl.name) return model.UnknownIntegerType(decl.name) diff --git a/cffi/verifier.py b/cffi/verifier.py index 5b0c135..d38866a 100644 --- a/cffi/verifier.py +++ b/cffi/verifier.py @@ -28,6 +28,10 @@ class Verifier(object): def __init__(self, ffi, preamble, tmpdir=None, modulename=None, ext_package=None, tag='', force_generic_engine=False, source_extension='.c', flags=None, relative_to=None, **kwds): + if ffi._parser._uses_new_feature: + raise ffiplatform.VerificationError( + "feature not supported with ffi.verify(), but only " + "with ffi.set_source(): %s" % (ffi._parser._uses_new_feature,)) self.ffi = ffi self.preamble = preamble if not modulename: diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index 3bc10d5..d0af856 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -2235,3 +2235,15 @@ def test_const_struct_global(): "const T myglob = { 0.1, 42 };") assert ffi.typeof(lib.myglob) == ffi.typeof("T") assert lib.myglob.x == 42 + +def test_dont_support_int_dotdotdot(): + ffi = FFI() + ffi.cdef("typedef int... t1;") + e = py.test.raises(VerificationError, ffi.verify, "") + assert str(e.value) == ("feature not supported with ffi.verify(), but only " + "with ffi.set_source(): 'typedef int... t1'") + ffi = FFI() + ffi.cdef("typedef unsigned long... t1;") + e = py.test.raises(VerificationError, ffi.verify, "") + assert str(e.value) == ("feature not supported with ffi.verify(), but only " + "with ffi.set_source(): 'typedef unsigned long... t1'") |
