[3.12] gh-105059: Use GCC/clang extension for PyObject union (GH-107232) (#107236)

gh-105059: Use GCC/clang extension for PyObject union (GH-107232)

Anonymous union is new in C11. To prevent compiler warning
when using -pedantic compiler option, use Clang and GCC
extension on C99 and older.
(cherry picked from commit 6261585d63)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2023-07-25 06:01:24 -07:00 committed by GitHub
parent fab36fb63e
commit 0cf5f6a6db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -165,6 +165,11 @@ check by comparing the reference count field to the immortality reference count.
*/
struct _object {
_PyObject_HEAD_EXTRA
#if (defined(__GNUC__) || defined(__clang__)) \
&& !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)
// On C99 and older, anonymous union is a GCC and clang extension
__extension__
#endif
union {
Py_ssize_t ob_refcnt;
#if SIZEOF_VOID_P > 4