This encapsulates the condition for in which cases the pragmas are enabled, and allows easily using them in more locations.
Signed-off-by: Martin Storsjö <[email protected]> --- mingw-w64-crt/include/internal.h | 11 +++++++++++ mingw-w64-crt/misc/imaxdiv.c | 15 ++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mingw-w64-crt/include/internal.h b/mingw-w64-crt/include/internal.h index a01f704f4..0c9778876 100644 --- a/mingw-w64-crt/include/internal.h +++ b/mingw-w64-crt/include/internal.h @@ -305,6 +305,17 @@ static inline unsigned int __mingw_statusfp(void) #endif +#if defined(__GNUC__) && __GNUC__ >= 8 +#define PRAGMA_DIAGNOSTIC_IGNORED_ATTRIBUTE_ALIAS_BEGIN \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wattribute-alias\"") +#define PRAGMA_DIAGNOSTIC_IGNORED_ATTRIBUTE_ALIAS_END \ + _Pragma ("GCC diagnostic pop") +#else +#define PRAGMA_DIAGNOSTIC_IGNORED_ATTRIBUTE_ALIAS_BEGIN +#define PRAGMA_DIAGNOSTIC_IGNORED_ATTRIBUTE_ALIAS_END +#endif + #ifdef __cplusplus } #endif diff --git a/mingw-w64-crt/misc/imaxdiv.c b/mingw-w64-crt/misc/imaxdiv.c index 8a6fb02c5..fb380c52c 100644 --- a/mingw-w64-crt/misc/imaxdiv.c +++ b/mingw-w64-crt/misc/imaxdiv.c @@ -17,6 +17,7 @@ #include <inttypes.h> #include <stdlib.h> +#include "internal.h" imaxdiv_t __cdecl @@ -29,19 +30,11 @@ imaxdiv(intmax_t numer, intmax_t denom) } imaxdiv_t (__cdecl *__MINGW_IMP_SYMBOL(imaxdiv))(intmax_t, intmax_t) = imaxdiv; -/* - * avoid gcc 8+ warning: - * 'lldiv' alias between functions of incompatible types 'lldiv_t(long long int, long long int)' {aka 'struct <anonymous>(long long int, long long int)'} and 'imaxdiv_t(intmax_t, intmax_t)' {aka 'struct <anonymous>(long long int, long long int)'} - */ -#if defined(__GNUC__) && __GNUC__ >= 8 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wattribute-alias" -#endif +PRAGMA_DIAGNOSTIC_IGNORED_ATTRIBUTE_ALIAS_BEGIN lldiv_t __attribute__ ((alias ("imaxdiv"))) __cdecl lldiv (long long, long long); extern lldiv_t __attribute__ ((alias (__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(imaxdiv))))) (__cdecl *__MINGW_IMP_SYMBOL(lldiv))(long long, long long); -#if defined(__GNUC__) && __GNUC__ >= 8 -#pragma GCC diagnostic pop -#endif + +PRAGMA_DIAGNOSTIC_IGNORED_ATTRIBUTE_ALIAS_END -- 2.43.0 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
