bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)
Fix invalid function cast warnings with gcc 8
for method conventions different from METH_NOARGS, METH_O and
METH_VARARGS excluding Argument Clinic generated code.
diff --git a/Objects/call.c b/Objects/call.c
index ba2ddcb..be8e90d 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -514,7 +514,7 @@
}
if (flags & METH_KEYWORDS) {
- result = (*(PyCFunctionWithKeywords)meth) (self, argstuple, kwargs);
+ result = (*(PyCFunctionWithKeywords)(void(*)(void))meth) (self, argstuple, kwargs);
}
else {
result = (*meth) (self, argstuple);
@@ -529,7 +529,7 @@
goto no_keyword_error;
}
- result = (*(_PyCFunctionFast)meth) (self, args, nargs);
+ result = (*(_PyCFunctionFast)(void(*)(void))meth) (self, args, nargs);
break;
}
@@ -537,7 +537,7 @@
{
PyObject *const *stack;
PyObject *kwnames;
- _PyCFunctionFastWithKeywords fastmeth = (_PyCFunctionFastWithKeywords)meth;
+ _PyCFunctionFastWithKeywords fastmeth = (_PyCFunctionFastWithKeywords)(void(*)(void))meth;
if (_PyStack_UnpackDict(args, nargs, kwargs, &stack, &kwnames) < 0) {
goto exit;
@@ -650,12 +650,12 @@
if (nkwargs) {
goto no_keyword_error;
}
- result = ((_PyCFunctionFast)meth) (self, args, nargs);
+ result = ((_PyCFunctionFast)(void(*)(void))meth) (self, args, nargs);
break;
case METH_FASTCALL | METH_KEYWORDS:
/* Fast-path: avoid temporary dict to pass keyword arguments */
- result = ((_PyCFunctionFastWithKeywords)meth) (self, args, nargs, kwnames);
+ result = ((_PyCFunctionFastWithKeywords)(void(*)(void))meth) (self, args, nargs, kwnames);
break;
case METH_VARARGS:
@@ -689,7 +689,7 @@
kwdict = NULL;
}
- result = (*(PyCFunctionWithKeywords)meth) (self, argtuple, kwdict);
+ result = (*(PyCFunctionWithKeywords)(void(*)(void))meth) (self, argtuple, kwdict);
Py_XDECREF(kwdict);
}
else {
@@ -752,7 +752,7 @@
return NULL;
}
- result = (*(PyCFunctionWithKeywords)meth)(self, args, kwargs);
+ result = (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, args, kwargs);
Py_LeaveRecursiveCall();
}