aboutsummaryrefslogtreecommitdiff
path: root/diag-control.h
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-03-21 14:02:56 -0700
committerGuy Harris <gharris@sonic.net>2022-03-21 14:04:25 -0700
commitbc8383304304a70a20c74bbc2fdcb0bb45b633c5 (patch)
tree01523bcf22e79f8af8aa31c57f4961788cd772d2 /diag-control.h
parent27169a09864bb90211e49979bb9950cbf89f8040 (diff)
downloadlibpcap-bc8383304304a70a20c74bbc2fdcb0bb45b633c5.tar.gz
Test PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) before testing _MSC_VER.
As Gisle Vanem notes, "...using clang-cl on Windows to compile with (a MSVC-compatible compiler driver), this includes _MSC_VER as a built-in. Hence the above blocks should be swapped..." This fixes issue #1101. (cherry picked from commit 49c94a759ccfebf157d549954b5254ecc39ee53d)
Diffstat (limited to 'diag-control.h')
-rw-r--r--diag-control.h113
1 files changed, 58 insertions, 55 deletions
diff --git a/diag-control.h b/diag-control.h
index d1622aa6..28624306 100644
--- a/diag-control.h
+++ b/diag-control.h
@@ -86,44 +86,7 @@
/*
* Suppress Flex, narrowing, and deprecation warnings.
*/
-#if defined(_MSC_VER)
- /*
- * This is Microsoft Visual Studio; we can use __pragma(warning(disable:XXXX))
- * and __pragma(warning(push/pop)).
- *
- * Suppress signed-vs-unsigned comparison, narrowing, and unreachable
- * code warnings.
- */
- #define DIAG_OFF_FLEX \
- __pragma(warning(push)) \
- __pragma(warning(disable:4127)) \
- __pragma(warning(disable:4242)) \
- __pragma(warning(disable:4244)) \
- __pragma(warning(disable:4702))
- #define DIAG_ON_FLEX \
- __pragma(warning(pop))
-
- /*
- * Suppress narrowing warnings.
- */
- #define DIAG_OFF_NARROWING \
- __pragma(warning(push)) \
- __pragma(warning(disable:4242)) \
- __pragma(warning(disable:4311))
- #define DIAG_ON_NARROWING \
- __pragma(warning(pop))
-
- /*
- * Suppress deprecation warnings.
- */
- #define DIAG_OFF_DEPRECATION \
- __pragma(warning(push)) \
- __pragma(warning(disable:4996))
- #define DIAG_ON_DEPRECATION \
- __pragma(warning(pop))
- #define DIAG_OFF_FORMAT_TRUNCATION
- #define DIAG_ON_FORMAT_TRUNCATION
-#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
+#if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
/*
* This is Clang 2.8 or later; we can use "clang diagnostic
* ignored -Wxxx" and "clang diagnostic push/pop".
@@ -132,6 +95,9 @@
* at least according to the GCC 7.3 documentation. Apparently, Flex
* generates code that upsets at least some versions of Clang's
* -Wdocumentation.
+ *
+ * (This could be clang-cl, which defines _MSC_VER, so test this
+ * before testing _MSC_VER.)
*/
#define DIAG_OFF_FLEX \
PCAP_DO_PRAGMA(clang diagnostic push) \
@@ -164,6 +130,43 @@
PCAP_DO_PRAGMA(clang diagnostic pop)
#define DIAG_OFF_FORMAT_TRUNCATION
#define DIAG_ON_FORMAT_TRUNCATION
+#elif defined(_MSC_VER)
+ /*
+ * This is Microsoft Visual Studio; we can use __pragma(warning(disable:XXXX))
+ * and __pragma(warning(push/pop)).
+ *
+ * Suppress signed-vs-unsigned comparison, narrowing, and unreachable
+ * code warnings.
+ */
+ #define DIAG_OFF_FLEX \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4127)) \
+ __pragma(warning(disable:4242)) \
+ __pragma(warning(disable:4244)) \
+ __pragma(warning(disable:4702))
+ #define DIAG_ON_FLEX \
+ __pragma(warning(pop))
+
+ /*
+ * Suppress narrowing warnings.
+ */
+ #define DIAG_OFF_NARROWING \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4242)) \
+ __pragma(warning(disable:4311))
+ #define DIAG_ON_NARROWING \
+ __pragma(warning(pop))
+
+ /*
+ * Suppress deprecation warnings.
+ */
+ #define DIAG_OFF_DEPRECATION \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4996))
+ #define DIAG_ON_DEPRECATION \
+ __pragma(warning(pop))
+ #define DIAG_OFF_FORMAT_TRUNCATION
+ #define DIAG_ON_FORMAT_TRUNCATION
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
/*
* This is GCC 4.6 or later, or a compiler claiming to be that.
@@ -241,21 +244,21 @@
* In addition, the generated code may have functions with unreachable
* code, so suppress warnings about those.
*/
- #if defined(_MSC_VER)
+ #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
/*
- * This is Microsoft Visual Studio; we can use
- * __pragma(warning(disable:XXXX)).
+ * This is Clang 2.8 or later (including clang-cl, so test this
+ * before _MSC_VER); we can use "clang diagnostic ignored -Wxxx".
*/
#define DIAG_OFF_BISON_BYACC \
- __pragma(warning(disable:4702))
- #elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
+ PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \
+ PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
+ #elif defined(_MSC_VER)
/*
- * This is Clang 2.8 or later; we can use "clang diagnostic
- * ignored -Wxxx".
+ * This is Microsoft Visual Studio; we can use
+ * __pragma(warning(disable:XXXX)).
*/
#define DIAG_OFF_BISON_BYACC \
- PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \
- PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
+ __pragma(warning(disable:4702))
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
/*
* This is GCC 4.6 or later, or a compiler claiming to be that.
@@ -279,7 +282,14 @@
* The generated code may have functions with unreachable code and
* switches with only a default case, so suppress warnings about those.
*/
- #if defined(_MSC_VER)
+ #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
+ /*
+ * This is Clang 2.8 or later (including clang-cl, so test this
+ * before _MSC_VER); we can use "clang diagnostic ignored -Wxxx".
+ */
+ #define DIAG_OFF_BISON_BYACC \
+ PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
+ #elif defined(_MSC_VER)
/*
* This is Microsoft Visual Studio; we can use
* __pragma(warning(disable:XXXX)).
@@ -292,13 +302,6 @@
__pragma(warning(disable:4242)) \
__pragma(warning(disable:4244)) \
__pragma(warning(disable:4702))
- #elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
- /*
- * This is Clang 2.8 or later; we can use "clang diagnostic
- * ignored -Wxxx".
- */
- #define DIAG_OFF_BISON_BYACC \
- PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
/*
* This is GCC 4.6 or later, or a compiler claiming to be that.