Skip to content

Commit 7a312ff

Browse files
committed
test_cext: Enable -pedantic-errors under GCC & clang
1 parent 56e1900 commit 7a312ff

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Lib/test/test_cext/extension.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,24 @@ _testcext_exec(
5858
return 0;
5959
}
6060

61+
// Converting from function pointer to void* has undefined behavior, but
62+
// works on all known platforms, and CPython's module and type slots currently
63+
// need it.
64+
// (GCC doesn't have a narrower category for this than -Wpedantic.)
65+
_Py_COMP_DIAG_PUSH
66+
#if defined(__GNUC__)
67+
#pragma GCC diagnostic ignored "-Wpedantic"
68+
#elif defined(__clang__)
69+
#pragma clang diagnostic ignored "-Wpedantic"
70+
#endif
71+
6172
static PyModuleDef_Slot _testcext_slots[] = {
6273
{Py_mod_exec, (void*)_testcext_exec},
6374
{0, NULL}
6475
};
6576

77+
_Py_COMP_DIAG_POP
78+
6679

6780
PyDoc_STRVAR(_testcext_doc, "C test extension.");
6881

Lib/test/test_cext/setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
# gh-120593: Check the 'const' qualifier
2323
'-Wcast-qual',
24+
25+
# Ask for strict(er) compliance with the standard
26+
'-pedantic-errors',
2427
]
2528
if not support.Py_GIL_DISABLED:
2629
CFLAGS.append(

0 commit comments

Comments
 (0)