Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Silence the GCC warning in a more local way. It's a GCC bug.
  • Loading branch information
encukou committed Nov 26, 2024
commit fcae66bf1f432d7ba8fa85f60e018986bc8ec461
5 changes: 0 additions & 5 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,25 +288,20 @@ extern "C" {
#define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push")
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS
#define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop")
#elif defined(__GNUC__) \
&& ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
#define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push")
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
#define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
#define _Py_COMP_DIAG_PUSH __pragma(warning(push))
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996))
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS
#define _Py_COMP_DIAG_POP __pragma(warning(pop))
#else
#define _Py_COMP_DIAG_PUSH
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS
#define _Py_COMP_DIAG_POP
#endif

Expand Down
18 changes: 13 additions & 5 deletions Modules/_ctypes/cfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,12 +1283,20 @@ for nbytes in 8, 16, 32, 64:
Py_UNREACHABLE();
}

/* Macro to call _ctypes_fixint_fielddesc for a given C type.
* The signedness check expands an expression that's always true or false;
* we silence the GCC warning '-Wtype-limits' for this.
*/

/* Macro to call _ctypes_fixint_fielddesc for a given C type. */

_Py_COMP_DIAG_PUSH
_Py_COMP_DIAG_IGNORE_TYPE_LIMITS
#if defined(__GNUC__) && (__GNUC__ < 14)
/* The signedness check expands to an expression that's always true or false.
* Older GCC gives a '-Wtype-limits' warning for this, which is a GCC bug
* (docs say it should "not warn for constant expressions"):
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86647
* Silence that warning.
*/
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif

#define FIXINT_FIELDDESC_FOR(C_TYPE) \
_ctypes_fixint_fielddesc(sizeof(C_TYPE), (C_TYPE)-1 < 0)

Expand Down