Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2134:1e7ca6f81db8
Date: 2015-05-30 14:11 +0200
http://bitbucket.org/cffi/cffi/changeset/1e7ca6f81db8/
Log: Check that the types declared with "typedef int... foo_t;" are
really integer types, using a "<< 0" hack.
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -1088,7 +1088,8 @@
self.cffi_types[index] = CffiOp(OP_PRIMITIVE, prim_index)
def _emit_bytecode_UnknownIntegerType(self, tp, index):
- s = '_cffi_prim_int(sizeof(%s), ((%s)-1) <= 0)' % (tp.name, tp.name)
+ s = '_cffi_prim_int(sizeof(%s), (((%s)-1) << 0) <= 0)' % (
+ tp.name, tp.name)
self.cffi_types[index] = CffiOp(OP_PRIMITIVE, s)
def _emit_bytecode_RawFunctionType(self, tp, index):
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -1,5 +1,5 @@
import sys, os, py
-from cffi import FFI, FFIError, VerificationError
+from cffi import FFI, VerificationError
from cffi import recompiler
from testing.udir import udir
from testing.support import u
@@ -970,10 +970,6 @@
assert lib.mu == -20
assert lib.nu == 20
-def test_unsupported_some_void_type():
- ffi = FFI()
- py.test.raises(FFIError, ffi.cdef, """typedef void... foo_t;""")
-
def test_some_float_type():
py.test.skip("later")
ffi = FFI()
diff --git a/testing/cffi1/test_verify1.py b/testing/cffi1/test_verify1.py
--- a/testing/cffi1/test_verify1.py
+++ b/testing/cffi1/test_verify1.py
@@ -1,5 +1,5 @@
import os, sys, math, py
-from cffi import FFI, VerificationError, VerificationMissing, model
+from cffi import FFI, FFIError, VerificationError, VerificationMissing, model
from cffi import recompiler
from testing.support import *
import _cffi_backend
@@ -2229,3 +2229,10 @@
return 3 + 4
x = lib.InvokeFunction(add)
assert x == 7
+
+def test_unsupported_some_primitive_types():
+ ffi = FFI()
+ py.test.raises(FFIError, ffi.cdef, """typedef void... foo_t;""")
+ #
+ ffi.cdef("typedef int... foo_t;")
+ py.test.raises(VerificationError, ffi.verify, "typedef float foo_t;")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit