aboutsummaryrefslogtreecommitdiffstats
path: root/ws_diag_control.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-09-11 18:53:56 +0000
committerGuy Harris <guy@alum.mit.edu>2018-09-11 18:54:02 +0000
commit420766099630d0fdcf403e93f5cfffc52889f7ce (patch)
tree040d10e61c0b24d7de76bca293dec496ff1cf282 /ws_diag_control.h
parentb7685821c10f37009cebe22810c2fdd63b05cd32 (diff)
Revert "Make versions of DIAG_OFF() and DIAG_ON() for GCC 4.2 through 4.5."
This reverts commit f6b8bc39c66c878ff25a4f48fff382f8775a2711. Reason for revert: prior to 4.6 or so, the pragmas didn't work as well, e.g. they couldn't be used inside a function; we depend on them being usable within a function. Change-Id: I7a7a0c08a2aca553233c237b8b6c43115095804e Reviewed-on: https://code.wireshark.org/review/29610 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ws_diag_control.h')
-rw-r--r--ws_diag_control.h86
1 files changed, 14 insertions, 72 deletions
diff --git a/ws_diag_control.h b/ws_diag_control.h
index 1dadd0241a..52799f540b 100644
--- a/ws_diag_control.h
+++ b/ws_diag_control.h
@@ -43,12 +43,6 @@ extern "C" {
/*
* This is Clang 2.8 or later: we can use "clang diagnostic ignored -Wxxx"
* and "clang diagnostic push/pop".
- *
- * The good news is that this can be used for diagnostics that
- * might be errors or might just be warnings. The bad news is
- * that DIAG_ON() just undoes the results of the most recent
- * DIAG_OFF(), independent of its argument, so you have to be
- * careful in how you nest them.
*/
#define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
#define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
@@ -56,20 +50,13 @@ extern "C" {
#endif
/*
- * Not all versions of Clang understand -Wpedantic.
+ * Not all versions of Clang understand -Wpedantic. Clang 4.0 appears
+ * to be the first version to do so.
*/
#if WS_IS_AT_LEAST_CLANG_VERSION(4,0)
- /*
- * This is Clang 4.0, which appears to be the first version to
- * support -Wpedantic.
- */
#define DIAG_OFF_PEDANTIC DIAG_OFF(pedantic)
#define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
#else
- /*
- * -Wpedantic isn't supported, so there's nothing to turn on or
- * off, and we can't turn it on or off in any case.
- */
#define DIAG_OFF_PEDANTIC
#define DIAG_ON_PEDANTIC
#endif
@@ -79,69 +66,24 @@ extern "C" {
* We assume that the compiler accepts _Pragma("GCC diagnostic xxx")
* even if it's only claiming to be GCC.
*/
- #if WS_IS_AT_LEAST_GNUC_VERSION(4,2)
+ #if WS_IS_AT_LEAST_GNUC_VERSION(4,8)
/*
- * This is GCC 4.2 or later, or a compiler claiming to be that.
- * We can use "GCC diagnostic ignored -Wxxx"; we may or may
- * not be able to use "GCC diagnostic push/pop" (introduced in 4.6).
+ * This is GCC 4.8 or later, or a compiler claiming to be that.
+ * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2)
+ * and "GCC diagnostic push/pop" (introduced in 4.6), *and* gcc
+ * supports "-Wpedantic" (introduced in 4.8), allowing us to
+ * turn off pedantic warnings with DIAG_OFF().
*/
#define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
- #if WS_IS_AT_LEAST_GNUC_VERSION(4,6)
- /*
- * This is GCC 4.6 or later, or a compiler claiming to be that.
- * We can use "GCC diagnostic push/pop".
- *
- * The good news is that this can be used for diagnostics that
- * might be errors or might just be warnings. The bad news is
- * that DIAG_ON() just undoes the results of the most recent
- * DIAG_OFF(), independent of its argument, so you have to be
- * careful in how you nest them.
- */
- #define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
- #define DIAG_ON(x) DIAG_PRAGMA(pop)
-
- #if WS_IS_AT_LEAST_GNUC_VERSION(4,8)
- /*
- * This is GCC 4.8, which supports -Wpedantic.
- */
- #define DIAG_OFF_PEDANTIC DIAG_OFF(pedantic)
- #define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
- #else /* WS_IS_AT_LEAST_GNUC_VERSION(4,8) */
- /*
- * -Wpedantic isn't supported, so there's nothing to turn on or
- * off, and we can't turn it on or off in any case.
- */
- #define DIAG_OFF_PEDANTIC
- #define DIAG_ON_PEDANTIC
- #endif /* WS_IS_AT_LEAST_GNUC_VERSION(4,8) */
- #else /* WS_IS_AT_LEAST_GNUC_VERSION(4,6) */
- /*
- * This is GCC 4.2 through 4.5; we can't use push and pop to turn
- * diagnostics on or off, but we can, at least, use "error" to
- * turn a diagnostic back on.
- *
- * The good news is that DIAG_ON() really *does* turn the
- * diagnostic in question back on, so you don't have to worry
- * about nesting them correctly. The bad news is that if you
- * use it on a diagnostic that's not supposed to be an error,
- * it'll become an error anyway.
- */
- #define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
- #define DIAG_ON(x) DIAG_PRAGMA(error DIAG_JOINSTR(-W,x))
+ #define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+ #define DIAG_ON(x) DIAG_PRAGMA(pop)
- /*
- * -Wpedantic isn't supported, so there's nothing to turn on or
- * off, and we can't turn it on or off in any case.
- */
- #define DIAG_OFF_PEDANTIC
- #define DIAG_ON_PEDANTIC
- #endif /* WS_IS_AT_LEAST_GNUC_VERSION(4,6) */
- #else /* WS_IS_AT_LEAST_GNUC_VERSION(4,2) */
/*
- * This is GCC prior to 4.2 -Wpedantic isn't supported, so there's
- * nothing to turn on or off, and we can't turn it on or off in any
- * case.
+ * We assume GCC 4.8 and later understand -Wpedantic.
*/
+ #define DIAG_OFF_PEDANTIC DIAG_OFF(pedantic)
+ #define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
+ #else
#define DIAG_OFF_PEDANTIC
#define DIAG_ON_PEDANTIC
#endif