forked from osmocom/wireshark
Revert "Make versions of DIAG_OFF() and DIAG_ON() for GCC 4.2 through 4.5."
This reverts commit f6b8bc39c6
.
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>
This commit is contained in:
parent
b7685821c1
commit
4207660996
|
@ -43,12 +43,6 @@ extern "C" {
|
||||||
/*
|
/*
|
||||||
* This is Clang 2.8 or later: we can use "clang diagnostic ignored -Wxxx"
|
* This is Clang 2.8 or later: we can use "clang diagnostic ignored -Wxxx"
|
||||||
* and "clang diagnostic push/pop".
|
* 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_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
|
||||||
#define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
|
#define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
|
||||||
|
@ -56,20 +50,13 @@ extern "C" {
|
||||||
#endif
|
#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)
|
#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_OFF_PEDANTIC DIAG_OFF(pedantic)
|
||||||
#define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
|
#define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
|
||||||
#else
|
#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_OFF_PEDANTIC
|
||||||
#define DIAG_ON_PEDANTIC
|
#define DIAG_ON_PEDANTIC
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,69 +66,24 @@ extern "C" {
|
||||||
* We assume that the compiler accepts _Pragma("GCC diagnostic xxx")
|
* We assume that the compiler accepts _Pragma("GCC diagnostic xxx")
|
||||||
* even if it's only claiming to be GCC.
|
* 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.
|
* This is GCC 4.8 or later, or a compiler claiming to be that.
|
||||||
* We can use "GCC diagnostic ignored -Wxxx"; we may or may
|
* We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2)
|
||||||
* not be able to use "GCC diagnostic push/pop" (introduced in 4.6).
|
* 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)
|
#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_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
|
||||||
#define DIAG_ON(x) DIAG_PRAGMA(pop)
|
#define DIAG_ON(x) DIAG_PRAGMA(pop)
|
||||||
|
|
||||||
#if WS_IS_AT_LEAST_GNUC_VERSION(4,8)
|
|
||||||
/*
|
/*
|
||||||
* This is GCC 4.8, which supports -Wpedantic.
|
* We assume GCC 4.8 and later understand -Wpedantic.
|
||||||
*/
|
*/
|
||||||
#define DIAG_OFF_PEDANTIC DIAG_OFF(pedantic)
|
#define DIAG_OFF_PEDANTIC DIAG_OFF(pedantic)
|
||||||
#define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
|
#define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
|
||||||
#else /* WS_IS_AT_LEAST_GNUC_VERSION(4,8) */
|
#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 /* 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))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* -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.
|
|
||||||
*/
|
|
||||||
#define DIAG_OFF_PEDANTIC
|
#define DIAG_OFF_PEDANTIC
|
||||||
#define DIAG_ON_PEDANTIC
|
#define DIAG_ON_PEDANTIC
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue