Skip to content

Commit fcae66b

Browse files
committed
Silence the GCC warning in a more local way. It's a GCC bug.
1 parent 144a3b0 commit fcae66b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

Include/pyport.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,25 +288,20 @@ extern "C" {
288288
#define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push")
289289
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
290290
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
291-
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS
292291
#define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop")
293292
#elif defined(__GNUC__) \
294293
&& ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
295294
#define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push")
296295
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
297296
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
298-
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS \
299-
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
300297
#define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop")
301298
#elif defined(_MSC_VER)
302299
#define _Py_COMP_DIAG_PUSH __pragma(warning(push))
303300
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996))
304-
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS
305301
#define _Py_COMP_DIAG_POP __pragma(warning(pop))
306302
#else
307303
#define _Py_COMP_DIAG_PUSH
308304
#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS
309-
#define _Py_COMP_DIAG_IGNORE_TYPE_LIMITS
310305
#define _Py_COMP_DIAG_POP
311306
#endif
312307

Modules/_ctypes/cfield.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,12 +1283,20 @@ for nbytes in 8, 16, 32, 64:
12831283
Py_UNREACHABLE();
12841284
}
12851285

1286-
/* Macro to call _ctypes_fixint_fielddesc for a given C type.
1287-
* The signedness check expands an expression that's always true or false;
1288-
* we silence the GCC warning '-Wtype-limits' for this.
1289-
*/
1286+
1287+
/* Macro to call _ctypes_fixint_fielddesc for a given C type. */
1288+
12901289
_Py_COMP_DIAG_PUSH
1291-
_Py_COMP_DIAG_IGNORE_TYPE_LIMITS
1290+
#if defined(__GNUC__) && (__GNUC__ < 14)
1291+
/* The signedness check expands to an expression that's always true or false.
1292+
* Older GCC gives a '-Wtype-limits' warning for this, which is a GCC bug
1293+
* (docs say it should "not warn for constant expressions"):
1294+
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86647
1295+
* Silence that warning.
1296+
*/
1297+
#pragma GCC diagnostic ignored "-Wtype-limits"
1298+
#endif
1299+
12921300
#define FIXINT_FIELDDESC_FOR(C_TYPE) \
12931301
_ctypes_fixint_fielddesc(sizeof(C_TYPE), (C_TYPE)-1 < 0)
12941302

0 commit comments

Comments
 (0)