diff options
author | Gerald Combs <gerald@zing.org> | 2015-02-14 13:36:45 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-02-14 22:55:00 +0000 |
commit | 65763cf6acb14d41ffbf37213268b2f64038e4f9 (patch) | |
tree | 14bf27cac8c973af602d27769464167988a3d880 | |
parent | 1b43a80c0d19244608b0d01ff483445504d2e563 (diff) |
Try to fix diagnostic suppression.
Test the compiler for "-Wpedantic" instead of "-pedantic" since DIAG_OFF
and DIAG_ON expect a "-W" flag prefix. Be more strict about the compiler
versions that DIAG_OFF and DIAG_ON support.
Change-Id: I9304c544912102f1719b79e9250f97b40a324430
Reviewed-on: https://code.wireshark.org/review/7123
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | wsutil/ws_diag_control.h | 39 |
3 files changed, 22 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index deedbad6c3..5a47b95697 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,7 +278,7 @@ else() set(WIRESHARK_EXTRA_COMPILER_COMMON_FLAGS # The following are for C and C++ - -pedantic + -Wpedantic # # Various code blocks this one. # diff --git a/configure.ac b/configure.ac index 8392611d8f..1896d08008 100644 --- a/configure.ac +++ b/configure.ac @@ -867,7 +867,7 @@ AC_ARG_ENABLE(extra-compiler-warnings, # # The following are for C and C++ # - AC_WIRESHARK_COMPILER_FLAGS_CHECK(-pedantic) + AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wpedantic) # # Various code blocks this one. # diff --git a/wsutil/ws_diag_control.h b/wsutil/ws_diag_control.h index c029dc1d98..be6df0353c 100644 --- a/wsutil/ws_diag_control.h +++ b/wsutil/ws_diag_control.h @@ -45,28 +45,29 @@ extern "C" { pragma clang diagnostic error/warning/ignored -Wxxx and pragma clang diagnostic push/pop were introduced in clang 2.8 */ -#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 && !defined(__clang__) - /* gcc version is >= 4.2.0; we can use "GCC diagnostic ignored/warning - -Wxxx" */ -# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x) -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 - /* gcc version is >= 4.6.0: we can use "GCC diagnostic push/pop" */ +#if defined(__GNUC__) && !defined(__clang__) +# define gcc_version ((__GNUC__ * 1000) + (__GNUC_MINOR__ * 10)) +# if gcc_version >= 4080 + /* + * gcc version is >= 4.8.0. We can use "GCC diagnostic push/pop" *and* + * gcc supports "-Wpedantic". + */ +# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x) # define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) # define DIAG_ON(x) DIAG_PRAGMA(pop) -# else - /* gcc version is between 4.2.0 and 4.6.0: - we can use "GCC diagnostic ignored/warning -Wxxx", but not - "GCC diagnostic push/pop" */ -# define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) -# define DIAG_ON(x) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x)) # endif -#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208) - /* clang version is >= 2.8: we can use "clang diagnostic ignored -Wxxx" - and "clang diagnostic push/pop" */ -# 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_ON(x) DIAG_PRAGMA(pop) -#else +#elif defined(__clang__) +# define clang_version ((__clang_major__ * 1000) + (__clang_minor__ * 10)) +# if clang_version >= 2080 + /* clang version is >= 2.8: we can use "clang diagnostic ignored -Wxxx" + and "clang diagnostic push/pop" */ +# 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_ON(x) DIAG_PRAGMA(pop) +# endif +#endif + +#ifndef DIAG_OFF /* no gcc or clang, or gcc version < 4.2.0, or clang version < 2.8: we can't do anything */ # define DIAG_OFF(x) |