Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r2186:17be464b073d
Date: 2015-06-15 09:04 +0200
http://bitbucket.org/cffi/cffi/changeset/17be464b073d/

Log:    Explicitly complain if we find 'typedef int... t;' in a call to
        verify()

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -102,6 +102,7 @@
         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 @@
         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
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -28,6 +28,10 @@
     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
--- a/testing/cffi0/test_verify.py
+++ b/testing/cffi0/test_verify.py
@@ -2235,3 +2235,15 @@
                      "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'")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to