crt: Make pragmas for ignoring -Wattribute-alias into a reusable macro

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ö <martin@martin.st>
diff --git a/mingw-w64-crt/include/internal.h b/mingw-w64-crt/include/internal.h
index 833b48a..19ac925 100644
--- a/mingw-w64-crt/include/internal.h
+++ b/mingw-w64-crt/include/internal.h
@@ -302,6 +302,17 @@
 
 #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 8a6fb02..fb380c5 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_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