]> The Tcpdump Group git mirrors - tcpdump/blobdiff - diag-control.h
bgp: Parse BGP extended message support capability
[tcpdump] / diag-control.h
index 8c9ca7214e04ab9b045362ebfb86220c71f9d365..3eb6bcaaf02094c5ac8c834339e81ec8b2d6238f 100644 (file)
   #define DIAG_DO_PRAGMA(x) _Pragma (#x)
 #endif
 
+/*
+ * XL C 12.1 and 13.1 for AIX require no attention in this department.
+ * XL C 16.1 defines both __GNUC__ and __clang__, so has to be tested first.
+ */
+#if ND_IS_AT_LEAST_XL_C_VERSION(16,1)
+  /*
+   * See respective Clang note below.
+   */
+  #define DIAG_OFF_ASSIGN_ENUM \
+    DIAG_DO_PRAGMA(clang diagnostic push) \
+    DIAG_DO_PRAGMA(clang diagnostic ignored "-Wassign-enum")
+  #define DIAG_ON_ASSIGN_ENUM \
+    DIAG_DO_PRAGMA(clang diagnostic pop)
+
+  #define DIAG_OFF_CAST_QUAL
+  #define DIAG_ON_CAST_QUAL
+  #define DIAG_OFF_DEPRECATION
+  #define DIAG_ON_DEPRECATION
 /*
  * The current clang compilers also define __GNUC__ and __GNUC_MINOR__
  * thus we need to test the clang case before the GCC one
  */
-#if ND_IS_AT_LEAST_CLANG_VERSION(2,8)
+#elif ND_IS_AT_LEAST_CLANG_VERSION(2,8)
   /*
    * Clang complains if you OR together multiple enum values of a
    * given enum type and them pass it as an argument of that enum
     DIAG_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
   #define DIAG_ON_DEPRECATION \
     DIAG_DO_PRAGMA(clang diagnostic pop)
-  #define DIAG_OFF_FORMAT_TRUNCATION
-  #define DIAG_ON_FORMAT_TRUNCATION
+
+  /*
+   * Clang supports the generic C11 extension even if run with the -std=gnu99
+   * flag, which leads FreeBSD <sys/cdefs.h> to use the extension, which
+   * results in Clang emitting a -Wc11-extensions warning. The warning is not
+   * documented in the user manual, but it happens with Clang 10.0.1 on
+   * FreeBSD 12.2, so let's use that as a reference.
+   */
+  #if ND_IS_AT_LEAST_CLANG_VERSION(10,0)
+    #define DIAG_OFF_C11_EXTENSIONS \
+      DIAG_DO_PRAGMA(clang diagnostic push) \
+      DIAG_DO_PRAGMA(clang diagnostic ignored "-Wc11-extensions")
+    #define DIAG_ON_C11_EXTENSIONS \
+      DIAG_DO_PRAGMA(clang diagnostic pop)
+  #endif
 #elif ND_IS_AT_LEAST_GNUC_VERSION(4,2)
   /* GCC apparently doesn't complain about ORing enums together. */
   #define DIAG_OFF_ASSIGN_ENUM
     DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
   #define DIAG_ON_DEPRECATION \
     DIAG_DO_PRAGMA(GCC diagnostic pop)
+  /*
+   * GCC supports -Wc99-c11-compat since version 5.1.0, but the warning does
+   * not trigger for now, so let's just leave it be.
+   */
 #else
   #define DIAG_OFF_ASSIGN_ENUM
   #define DIAG_ON_ASSIGN_ENUM
   #define DIAG_ON_DEPRECATION
 #endif
 
+#ifndef DIAG_OFF_C11_EXTENSIONS
+#define DIAG_OFF_C11_EXTENSIONS
+#endif
+#ifndef DIAG_ON_C11_EXTENSIONS
+#define DIAG_ON_C11_EXTENSIONS
+#endif
+
+/*
+ * GCC needs this on AIX for longjmp().
+ */
+#if ND_IS_AT_LEAST_GNUC_VERSION(5,1)
+  /*
+   * Beware that the effect of this builtin is more than just squelching the
+   * warning! GCC trusts it enough for the process to segfault if the control
+   * flow reaches the builtin (an infinite empty loop in the same context would
+   * squelch the warning and ruin the process too, albeit in a different way).
+   * So please remember to use this very carefully.
+   */
+  #define ND_UNREACHABLE __builtin_unreachable();
+#else
+  #define ND_UNREACHABLE
+#endif
+
 #endif /* _diag_control_h */