Muffle GCC warnings in various ways.
[u/mdw/catacomb] / key / key-data.h
index 9c00908..cfeff82 100644 (file)
@@ -160,10 +160,26 @@ typedef struct key_filter {
   unsigned m;
 } key_filter;
 
-/* --- Matching aginst key selection --- */
+/* --- Matching aginst key selection --- *
+ *
+ * GCC will warn about constant addresses in this test, which is rather
+ * unfortunate.  Muffle the warning.  This is rather hideous because of the
+ * way GCC's parser handles pragmata.
+ */
+
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#  define KEY_MATCH_MUFFLE_WARNING(x) __extension__ ({                 \
+       _Pragma("GCC diagnostic push")                                  \
+       _Pragma("GCC diagnostic ignored \"-Waddress\"")                 \
+       (x);                                                            \
+       _Pragma("GCC diagnostic pop")                                   \
+   })
+#else
+#  define KEY_MATCH_MUFFLE_WARNING(x) (x)
+#endif
 
 #define KEY_MATCH(kd, kf)                                              \
-  (!(kf) ||                                                            \
+  (KEY_MATCH_MUFFLE_WARNING(!(kf)) ||                                  \
    ((kd)->e & KF_ENCMASK) == KENC_STRUCT ||                            \
    ((kd)->e & (kf)->m) == (kf)->f)