Commit ae2776ad authored by Stefan Behnel's avatar Stefan Behnel

avoid C compiler warnings for different integer types and signedness when...

avoid C compiler warnings for different integer types and signedness when bounds-checking index in obj.pop() optimisation
parent f7ee3cbb
......@@ -2504,7 +2504,9 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform):
PyrexTypes.py_object_type, [
PyrexTypes.CFuncTypeArg("list", PyrexTypes.py_object_type, None),
PyrexTypes.CFuncTypeArg("index", PyrexTypes.c_py_ssize_t_type, None),
])
PyrexTypes.CFuncTypeArg("is_signed", PyrexTypes.c_int_type, None),
],
has_varargs=True) # to fake the additional macro args that lack a proper C type
def _handle_simple_method_list_pop(self, node, function, args, is_unbound_method):
return self._handle_simple_method_object_pop(
......@@ -2555,7 +2557,13 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform):
return ExprNodes.PythonCapiCallNode(
node.pos, "__Pyx_Py%s_PopIndex" % type_name,
self.PyObject_PopIndex_func_type,
args=[obj, index, ExprNodes.RawCNameExprNode(index.pos, conversion_type, convert_func)],
args=[obj, index,
ExprNodes.IntNode(index.pos, value=str(orig_index_type.signed and 1 or 0),
constant_result=orig_index_type.signed and 1 or 0,
type=PyrexTypes.c_int_type),
ExprNodes.RawCNameExprNode(index.pos, PyrexTypes.c_void_type,
orig_index_type.declaration_code("")),
ExprNodes.RawCNameExprNode(index.pos, conversion_type, convert_func)],
may_return_none=True,
is_temp=node.is_temp,
utility_code=load_c_utility("pop_index"),
......
......@@ -110,12 +110,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
/////////////// pop_index.proto ///////////////
#define __Pyx_PyObject_PopIndex(L, ix, to_py_func) ( \
(PyList_CheckExact(L) && likely(PY_SSIZE_T_MIN <= ix && ix <= PY_SSIZE_T_MAX)) ? \
#define __Pyx_PyObject_PopIndex(L, ix, is_signed, type, to_py_func) ( \
(PyList_CheckExact(L) && __Pyx_fits_Py_ssize_t(ix, type, is_signed)) ? \
__Pyx__PyList_PopIndex(L, ix) : __Pyx__PyObject_PopIndex(L, to_py_func(ix)))
#define __Pyx_PyList_PopIndex(L, ix, to_py_func) ( \
likely(PY_SSIZE_T_MIN <= ix && ix <= PY_SSIZE_T_MAX) ? \
#define __Pyx_PyList_PopIndex(L, ix, is_signed, type, to_py_func) ( \
__Pyx_fits_Py_ssize_t(ix, type, is_signed) ? \
__Pyx__PyList_PopIndex(L, ix) : __Pyx__PyObject_PopIndex(L, to_py_func(ix)))
static PyObject* __Pyx__PyList_PopIndex(PyObject* L, Py_ssize_t ix); /*proto*/
......
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