Commit 772a754e authored by Tristan Barback's avatar Tristan Barback Committed by Martin Marinov

Add new warning guard macro for CQI (#1)

* Add new warning guard macro for CQI: add a completely new macro rather than using
   the existing one as this will let us customise the behaviour without
   breaking any of the existing warning suppressions. In particular the
   warning level can be set to 3 even for the problem header files.

* Add unused variable macro.

* Minor whitespace correction
parent ba35e1ff
......@@ -5,57 +5,64 @@
// This file contains various definitions related to enforcing certain code
// quality rules, e.g., applying W4
// only test this in MSVC
#if defined(_MSC_VER)
// Some warnings are disabled permanently since the cannot be controlled on
// section basis.
// Some warnings are disabled permanently since the cannot be controlled on
// section basis.
//function 'function' marked as __forceinline not inlined
#pragma warning (disable: 4714)
//function 'function' marked as __forceinline not inlined
#pragma warning (disable: 4714)
#define LOW_CODE_QUALITY_SECTION_BEGIN __pragma(warning(push, 1))
#define LOW_CODE_QUALITY_SECTION_END __pragma(warning(pop))
#define LOW_CODE_QUALITY_SECTION_BEGIN1 __pragma(warning(push, 1))
#define LOW_CODE_QUALITY_SECTION_BEGIN3 __pragma(warning(push, 3))
#define LOW_CODE_QUALITY_SECTION_END __pragma(warning(pop))
#define LOW_CODE_QUALITY_VARIABLE_ALLOW(FOO) static_cast<void>(FOO);
#else
#else // not on MSVC
#if __cplusplus >= 201103L
#if __cplusplus >= 201103L
#ifdef __clang__
#ifdef __clang__
#define LOW_CODE_QUALITY_SECTION_BEGIN \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-register\"") \
_Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") \
_Pragma("clang diagnostic ignored \"-Wshift-negative-value\"")
//TODO: ignore more warnings as needed
#define LOW_CODE_QUALITY_SECTION_BEGIN1 \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-register\"") \
_Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") \
_Pragma("clang diagnostic ignored \"-Wshift-negative-value\"")
//TODO: ignore more warnings as needed
#define LOW_CODE_QUALITY_SECTION_END \
_Pragma("clang diagnostic pop")
#define LOW_CODE_QUALITY_SECTION_END \
_Pragma("clang diagnostic pop")
#elif defined(__GNUG__)
#elif defined(__GNUG__)
#define LOW_CODE_QUALITY_SECTION_BEGIN \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wall\"") //TODO: ignore more warnings as needed
#define LOW_CODE_QUALITY_SECTION_BEGIN1 \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wall\"") //TODO: ignore more warnings as needed
#define LOW_CODE_QUALITY_SECTION_END \
_Pragma("GCC diagnostic pop")
#define LOW_CODE_QUALITY_SECTION_END \
_Pragma("GCC diagnostic pop")
#else
#else
#define LOW_CODE_QUALITY_SECTION_BEGIN
#define LOW_CODE_QUALITY_SECTION_END
#define LOW_CODE_QUALITY_SECTION_END
#endif
#endif
#else
#else // __cplusplus < 201103L
#define LOW_CODE_QUALITY_SECTION_BEGIN
#define LOW_CODE_QUALITY_SECTION_END
#define LOW_CODE_QUALITY_SECTION_BEGIN1
#define LOW_CODE_QUALITY_SECTION_END
#endif
#endif // __cplusplus >= 201103L
#define LOW_CODE_QUALITY_SECTION_BEGIN3
#define LOW_CODE_QUALITY_VARIABLE_ALLOW(FOO) static_cast<void>(sizeof(FOO));
#endif // ifdef _MSC_VER
// backwards-compatible name for LOW_CODE_QUALITY_SECTION_BEGIN1
#define LOW_CODE_QUALITY_SECTION_BEGIN LOW_CODE_QUALITY_SECTION_BEGIN1
#endif // QUALITY_HH_INCLUDED
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment