diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-02-16 03:15:32 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-02-16 19:54:16 +0000 |
commit | 72b57ac4ef653c1909e4c1d1daf40de2357b77e8 (patch) | |
tree | 991ac5b78097abb80d1b83272fc247e601e0edf4 /ws_diag_control.h | |
parent | 09671923adcb745381fc4b276085d0ac7cb8ee94 (diff) |
Use DIAG_OFF_FLEX/DIAG_ON_FLEX more consistently.
Add warning C4267 (size_t to int conversion) with MSVC to DIAG_OFF_FLEX.
Addd -Wshorten-64-to-32 with Clang and GCC to DIAG_OFF_FLEX.
Don't explicitly use #pragma to turn off warnings; use DIAG_OFF_FLEX for
all of them.
If we use DIAG_OFF_FLEX, use DIAG_ON_FLEX, even if we have no section of
entirely included code at the end.
Change-Id: Ibfd44e8954704e9a8bcb1bd8e54f31d28357fffb
Reviewed-on: https://code.wireshark.org/review/25817
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ws_diag_control.h')
-rw-r--r-- | ws_diag_control.h | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/ws_diag_control.h b/ws_diag_control.h index 155c143077..e3ee28ed9c 100644 --- a/ws_diag_control.h +++ b/ws_diag_control.h @@ -100,15 +100,49 @@ extern "C" { * generated by that version of Flex triggers? */ #if defined(_MSC_VER) + /* + * Suppress: + * + * warning C4018: signed/unsigned mismatch + * warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data + */ #define DIAG_OFF_FLEX \ __pragma(warning(push)) \ - __pragma(warning(disable:4018)) + __pragma(warning(disable:4018)) \ + __pragma(warning(disable:4267)) #define DIAG_ON_FLEX __pragma(warning(pop)) #else - #define DIAG_OFF_FLEX \ - DIAG_OFF(sign-compare) - #define DIAG_ON_FLEX \ - DIAG_ON(sign-compare) + /* + * Suppress: + * + * -Wsigned-compare warnings + * -Wshorten-64-to-32 warnings, if the compiler *has* -Wshorten-64-to-32 + * + * We use DIAG_OFF() and DIAG_ON(), so we only use features that the + * compiler supports. + * + * We disable -Wshorten-64-to-32 if we're using Clang, or if __APPLE__ + * is defined; that option was originally added to an Apple version of + * GCC, and at least some versions of Clang support it - given that + * the Clang work started at Apple, it may be in all versions of Clang. + * + * (Does no version of GCC or Clang support the same generic "you're + * narrowing a value, and you didn't throw in a cast to assert that + * you know what you're doing" warning that MSVC does?) + */ + #if defined(__clang__) || defined(__APPLE__) + #define DIAG_OFF_FLEX \ + DIAG_OFF(sign-compare) \ + DIAG_OFF(shorten-64-to-32) + #define DIAG_ON_FLEX \ + DIAG_ON(shorten-64-to-32) \ + DIAG_ON(sign-compare) + #else + #define DIAG_OFF_FLEX \ + DIAG_OFF(sign-compare) + #define DIAG_ON_FLEX \ + DIAG_ON(sign-compare) + #endif #endif /* |