aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-11-19 22:52:09 +0000
committerJoão Valverde <j@v6e.pt>2022-11-20 10:11:27 +0000
commit79c3a77752bfee8e57cac3796d5e5ef1987e5612 (patch)
treedd903014caf5145faf5b220afa435d1b653044cf /include
parentc4ca4312c1c17cf48a1e956d0cd2e6ab5e04d4f2 (diff)
Add macros to control lemon diagnostics
Rename flex macros using parenthesis (mostly a style issue): DIAG_OFF_FLEX -> DIAG_OFF_FLEX() DIAG_ON_FLEX -> DIAG_ON_FLEX() Use the same kind of construct with lemon generated code using DIAG_OFF_LEMON() and DIAG_ON_LEMON(). Use %include and %code directives to enforce the desired order with generated code in the middle in between pragmas. Fix a clang-specific pragma to use DIAG_OFF_CLANG(). DIAG_OFF(unreachable-code) -> DIAG_OFF_CLANG(unreachable-code). Apparently GCC is ignoring the -Wunreachable flag, that's why it did not trigger an unknown pragma warning. From [1}: The -Wunreachable-code has been removed, because it was unstable: it relied on the optimizer, and so different versions of gcc would warn about different code. The compiler still accepts and ignores the command line option so that existing Makefiles are not broken. In some future release the option will be removed entirely. - Ian [1] https://gcc.gnu.org/legacy-ml/gcc-help/2011-05/msg00360.html
Diffstat (limited to 'include')
-rw-r--r--include/ws_diag_control.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/include/ws_diag_control.h b/include/ws_diag_control.h
index a1ca422694..c4f7500633 100644
--- a/include/ws_diag_control.h
+++ b/include/ws_diag_control.h
@@ -164,7 +164,7 @@ extern "C" {
* warning C6387: 'XXX' could be '0'
* warning C28182: Dereferencing NULL pointer
*/
- #define DIAG_OFF_FLEX \
+ #define DIAG_OFF_FLEX() \
__pragma(warning(push)) \
__pragma(warning(disable:4018)) \
__pragma(warning(disable:4244)) \
@@ -174,7 +174,8 @@ extern "C" {
__pragma(warning(disable:6386)) \
__pragma(warning(disable:6387)) \
__pragma(warning(disable:28182))
- #define DIAG_ON_FLEX __pragma(warning(pop))
+ #define DIAG_ON_FLEX() \
+ __pragma(warning(pop))
#else
/*
* Suppress:
@@ -198,24 +199,35 @@ extern "C" {
* you know what you're doing" warning that MSVC does?)
*/
#if defined(__clang__) || defined(__APPLE__)
- #define DIAG_OFF_FLEX \
+ #define DIAG_OFF_FLEX() \
DIAG_OFF(sign-compare) \
DIAG_OFF(shorten-64-to-32) \
DIAG_OFF(unreachable-code) \
DIAG_OFF(documentation)
- #define DIAG_ON_FLEX \
+ #define DIAG_ON_FLEX() \
DIAG_ON(documentation) \
DIAG_ON(unreachable-code) \
DIAG_ON(shorten-64-to-32) \
DIAG_ON(sign-compare)
#else
- #define DIAG_OFF_FLEX \
+ #define DIAG_OFF_FLEX() \
DIAG_OFF(sign-compare)
- #define DIAG_ON_FLEX \
+ #define DIAG_ON_FLEX() \
DIAG_ON(sign-compare)
#endif
#endif
+/* Disable Lemon warnings. */
+#if defined(_MSC_VER)
+ #define DIAG_OFF_LEMON()
+ #define DIAG_ON_LEMON()
+#else
+ #define DIAG_OFF_LEMON() \
+ DIAG_OFF_CLANG(unreachable-code)
+ #define DIAG_ON_LEMON() \
+ DIAG_ON_CLANG(unreachable-code)
+#endif
+
/*
* Suppress warnings about casting away constness.
* Do this only if you know that the pointer is to something that can