Use the shiny new `mLib' warning-control macros.
[u/mdw/catacomb] / math / mpint.h
index f551980..e351b05 100644 (file)
@@ -36,6 +36,8 @@
 
 #include <limits.h>
 
+#include <mLib/macros.h>
+
 #ifndef CATACOMB_MP_H
 #  include "mp.h"
 #endif
  *
  * GCC (at least) isn't clever enough to work out that the division in
  * @MP_FROMINT@ is actually safe (since it will only be executed if @_i >
- * MPW_MAX@, which would prove that @(type)MPW_MAX + 1 != 0@).  So here's
- * some machinery to shut it up.
+ * MPW_MAX@, which would prove that @(type)MPW_MAX + 1 != 0@).
  */
 
-#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-#  define MP_FROMINT_MUFFLE_WARNING(x) do {                            \
-       _Pragma("GCC diagnostic push")                                  \
-       _Pragma("GCC diagnostic ignored \"-Wdiv-by-zero\"")             \
-       x                                                               \
-       _Pragma("GCC diagnostic pop")                                   \
-   } while (0)
-#else
-#  define MP_FROMINT_MUFFLE_WARNING(x) do { x } while (0)
-#endif
-
 /* --- @MP_FROMINT@ --- *
  *
  * Arguments:  @d@ = destination multiprecision integer
@@ -90,7 +80,9 @@
       if (_i <= MPW_MAX)                                               \
        break;                                                          \
       else                                                             \
-       MP_FROMINT_MUFFLE_WARNING({ _i /= (type)MPW_MAX + 1; });        \
+       MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), {            \
+         _i /= (type)MPW_MAX + 1;                                      \
+       });                                                             \
     }                                                                  \
   } else {                                                             \
     _d->f |= MP_NEG;                                                   \
       if (_i >= -MPW_MAX)                                              \
        break;                                                          \
       else                                                             \
-       MP_FROMINT_MUFFLE_WARNING({ _i /= (type)MPW_MAX + 1; });        \
+       MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), {            \
+         _i /= (type)MPW_MAX + 1;                                      \
+       });                                                             \
     }                                                                  \
   }                                                                    \
                                                                        \