Commit 18e78e6f authored by Armin Rigo's avatar Armin Rigo
Browse files

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

parent 78ba2e4ab0ff
......@@ -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)
......@@ -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:
......
......@@ -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'")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment