Commits

Armin Rigo  committed 1f90b69

Fix.

  • Participants
  • Parent commits 4d29f1e

Comments (0)

Files changed (4)

File cffi/cparser.py

         tp.fldnames = tuple(fldnames)
         tp.fldtypes = tuple(fldtypes)
         tp.fldbitsize = tuple(fldbitsize)
+        if fldbitsize != [-1] * len(fldbitsize):
+            if isinstance(tp, model.StructType) and tp.partial:
+                raise NotImplementedError("%s: using both bitfields and '...;'"
+                                          % (tp,))
         return tp
 
     def _make_partial(self, tp):

File cffi/vengine_cpy.py

             prnt('  static Py_ssize_t nums[] = {')
             prnt('    sizeof(%s),' % cname)
             prnt('    offsetof(struct _cffi_aligncheck, y),')
-            for fname in tp.fldnames:
+            for fname, fbitsize in zip(tp.fldnames, tp.fldbitsize):
+                assert fbitsize < 0
                 prnt('    offsetof(%s, %s),' % (cname, fname))
                 prnt('    sizeof(((%s *)0)->%s),' % (cname, fname))
             prnt('    -1')
                 'sizeof(%s) != %d' % (cname, ffi.sizeof(BStruct)),
                 'offsetof(struct _cffi_aligncheck, y) != %d' % (
                     ffi.alignof(BStruct),)]
-            for fname, ftype in zip(tp.fldnames, tp.fldtypes):
+            for fname, ftype, fbitsize in zip(tp.fldnames, tp.fldtypes,
+                                              tp.fldbitsize):
+                if fbitsize >= 0:
+                    continue        # xxx ignore fbitsize for now
                 BField = ffi._get_cached_btype(ftype)
                 conditions += [
                     'offsetof(%s, %s) != %d' % (

File cffi/vengine_gen.py

             prnt('  static ssize_t nums[] = {')
             prnt('    1, sizeof(%s),' % cname)
             prnt('    offsetof(struct _cffi_aligncheck, y),')
-            for fname in tp.fldnames:
+            for fname, fbitsize in zip(tp.fldnames, tp.fldbitsize):
+                assert fbitsize < 0
                 prnt('    offsetof(%s, %s),' % (cname, fname))
                 prnt('    sizeof(((%s *)0)->%s),' % (cname, fname))
             prnt('    -1')
                 'sizeof(%s) != %d' % (cname, ffi.sizeof(BStruct)),
                 'offsetof(struct _cffi_aligncheck, y) != %d' % (
                     ffi.alignof(BStruct),)]
-            for fname, ftype in zip(tp.fldnames, tp.fldtypes):
+            for fname, ftype, fbitsize in zip(tp.fldnames, tp.fldtypes,
+                                              tp.fldbitsize):
+                if fbitsize >= 0:
+                    continue        # xxx ignore fbitsize for now
                 BField = ffi._get_cached_btype(ftype)
                 conditions += [
                     'offsetof(%s, %s) != %d' % (

File testing/test_verify.py

     py.test.raises(OverflowError, "s.b = 4")
     assert s.b == 3
 
+def test_unsupported_struct_with_bitfield_ellipsis():
+    ffi = FFI()
+    py.test.raises(NotImplementedError, ffi.cdef,
+                   "struct foo_s { int a:2, b:3; ...; };")
+
 def test_global_constants():
     ffi = FFI()
     # use 'static const int', as generally documented, although in this