gh-118124: fix assert related C++ checks on Solaris/Illumos (#121974)

Fix check for static_assert() for C++ on some platforms.
This commit is contained in:
Jakub Kulík 2024-07-21 18:50:14 +02:00 committed by GitHub
parent 0dcbc83853
commit e88bd96d0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -15,11 +15,11 @@
// MSVC makes static_assert a keyword in C11-17, contrary to the standards. // MSVC makes static_assert a keyword in C11-17, contrary to the standards.
// //
// In C++11 and C2x, static_assert is a keyword, redefining is undefined // In C++11 and C2x, static_assert is a keyword, redefining is undefined
// behaviour. So only define if building as C (if __STDC_VERSION__ is defined), // behaviour. So only define if building as C, not C++ (if __cplusplus is
// not C++, and only for C11-17. // not defined), and only for C11-17.
#if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \ #if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \
&& defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ && !defined(__cplusplus) && defined(__STDC_VERSION__) \
&& __STDC_VERSION__ <= 201710L && __STDC_VERSION__ >= 201112L && __STDC_VERSION__ <= 201710L
# define static_assert _Static_assert # define static_assert _Static_assert
#endif #endif
@ -47,7 +47,7 @@
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
&& !defined(_MSC_VER)) && !defined(__cplusplus) && !defined(_MSC_VER))
# define Py_BUILD_ASSERT_EXPR(cond) \ # define Py_BUILD_ASSERT_EXPR(cond) \
((void)sizeof(struct { int dummy; _Static_assert(cond, #cond); }), \ ((void)sizeof(struct { int dummy; _Static_assert(cond, #cond); }), \
0) 0)