]> The Tcpdump Group git mirrors - tcpdump/blobdiff - diag-control.h
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / diag-control.h
index c1ca6536ce87c13216a234bcb4d959317399e2c8..3eb6bcaaf02094c5ac8c834339e81ec8b2d6238f 100644 (file)
     DIAG_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
   #define DIAG_ON_DEPRECATION \
     DIAG_DO_PRAGMA(clang diagnostic pop)
+
+  /*
+   * 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 */