forked from pool/python-cffi
Add upstream patch to actually fix problem with gcc >= 6; drop previous patch used to workaround issue. OBS-URL: https://build.opensuse.org/request/show/398809 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-cffi?expand=0&rev=29
40 lines
1.8 KiB
Diff
40 lines
1.8 KiB
Diff
# HG changeset patch
|
|
# User Armin Rigo <arigo@tunes.org>
|
|
# Date 1464590378 -7200
|
|
# Node ID bc14c64da0f41ba70f6fab821540b376f78e0a85
|
|
# Parent f6d4b0a1e70b885352de186fcaeedf41365793c6
|
|
Issue #260: don't use "x << 0" but "x | 0" to check that x is an
|
|
integer. It seems that "x << 0" is undefined, according to the C
|
|
standard, if x is any negative value...
|
|
|
|
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
|
|
--- a/cffi/recompiler.py
|
|
+++ b/cffi/recompiler.py
|
|
@@ -814,7 +814,7 @@
|
|
try:
|
|
if ftype.is_integer_type() or fbitsize >= 0:
|
|
# accept all integers, but complain on float or double
|
|
- prnt(" (void)((p->%s) << 1); /* check that '%s.%s' is "
|
|
+ prnt(" (void)((p->%s) | 0); /* check that '%s.%s' is "
|
|
"an integer */" % (fname, cname, fname))
|
|
continue
|
|
# only accept exactly the type declared, except that '[]'
|
|
@@ -991,7 +991,7 @@
|
|
prnt('static int %s(unsigned long long *o)' % funcname)
|
|
prnt('{')
|
|
prnt(' int n = (%s) <= 0;' % (name,))
|
|
- prnt(' *o = (unsigned long long)((%s) << 0);'
|
|
+ prnt(' *o = (unsigned long long)((%s) | 0);'
|
|
' /* check that %s is an integer */' % (name, name))
|
|
if check_value is not None:
|
|
if check_value > 0:
|
|
@@ -1250,7 +1250,7 @@
|
|
|
|
def _emit_bytecode_UnknownIntegerType(self, tp, index):
|
|
s = ('_cffi_prim_int(sizeof(%s), (\n'
|
|
- ' ((%s)-1) << 0 /* check that %s is an integer type */\n'
|
|
+ ' ((%s)-1) | 0 /* check that %s is an integer type */\n'
|
|
' ) <= 0)' % (tp.name, tp.name, tp.name))
|
|
self.cffi_types[index] = CffiOp(OP_PRIMITIVE, s)
|
|
|