@@ -161,11 +161,24 @@ class VirtualPyObject : public PyObject {
161161
162162int VirtualPyObject::instance_count = 0 ;
163163
164+ // Converting from function pointer to void* has undefined behavior, but
165+ // works on all known platforms, and CPython's module and type slots currently
166+ // need it.
167+ // (GCC doesn't have a narrower category for this than -Wpedantic.)
168+ _Py_COMP_DIAG_PUSH
169+ #if defined(__GNUC__)
170+ #pragma GCC diagnostic ignored "-Wpedantic"
171+ #elif defined(__clang__)
172+ #pragma clang diagnostic ignored "-Wpedantic"
173+ #endif
174+
164175PyType_Slot VirtualPyObject_Slots[] = {
165176 {Py_tp_free, (void *)VirtualPyObject::dealloc},
166177 {0 , _Py_NULL},
167178};
168179
180+ _Py_COMP_DIAG_POP
181+
169182PyType_Spec VirtualPyObject_Spec = {
170183 /* .name */ STR (MODULE_NAME) " .VirtualPyObject" ,
171184 /* .basicsize */ sizeof (VirtualPyObject),
@@ -241,11 +254,20 @@ _testcppext_exec(PyObject *module)
241254 return 0 ;
242255}
243256
257+ // Need to ignore "-Wpedantic" warnings; see VirtualPyObject_Slots above
258+ _Py_COMP_DIAG_PUSH
259+ #if defined(__GNUC__)
260+ #pragma GCC diagnostic ignored "-Wpedantic"
261+ #elif defined(__clang__)
262+ #pragma clang diagnostic ignored "-Wpedantic"
263+ #endif
264+
244265static PyModuleDef_Slot _testcppext_slots[] = {
245266 {Py_mod_exec, reinterpret_cast <void *>(_testcppext_exec)},
246267 {0 , _Py_NULL}
247268};
248269
270+ _Py_COMP_DIAG_POP
249271
250272PyDoc_STRVAR (_testcppext_doc, " C++ test extension." );
251273
0 commit comments