diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-11-27 09:27:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-27 09:27:36 (GMT) |
commit | 4a934d490fac779d8954a8292369c4506bab23fa (patch) | |
tree | c481c9a26efba1d156bb04959a12e2aac3d2deff /Tools | |
parent | b619b097923155a7034c05c4018bf06af9f994d0 (diff) | |
download | cpython-4a934d490fac779d8954a8292369c4506bab23fa.zip cpython-4a934d490fac779d8954a8292369c4506bab23fa.tar.gz cpython-4a934d490fac779d8954a8292369c4506bab23fa.tar.bz2 |
bpo-33012: Fix invalid function cast warnings with gcc 8 in Argument Clinic. (GH-6748)
Fix invalid function cast warnings with gcc 8
for method conventions different from METH_NOARGS, METH_O and
METH_VARARGS in Argument Clinic generated code.
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/clinic/clinic.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index ca8096f..2df8071 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -680,7 +680,7 @@ class CLanguage(Language): methoddef_define = normalize_snippet(""" #define {methoddef_name} \\ - {{"{name}", (PyCFunction){c_basename}, {methoddef_flags}, {c_basename}__doc__}}, + {{"{name}", {methoddef_cast}{c_basename}, {methoddef_flags}, {c_basename}__doc__}}, """) if new_or_init and not f.docstring: docstring_prototype = docstring_definition = '' @@ -944,10 +944,16 @@ class CLanguage(Language): parser_definition = insert_keywords(parser_definition) + if flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'): + methoddef_cast = "(PyCFunction)" + else: + methoddef_cast = "(PyCFunction)(void(*)(void))" + if f.methoddef_flags: flags += '|' + f.methoddef_flags methoddef_define = methoddef_define.replace('{methoddef_flags}', flags) + methoddef_define = methoddef_define.replace('{methoddef_cast}', methoddef_cast) methoddef_ifndef = '' conditional = self.cpp.condition() |