From: kgv Date: Tue, 6 Nov 2018 13:07:21 +0000 (+0300) Subject: 0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_... X-Git-Tag: V7_4_0_beta~332 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=8946be34223ee6fa1c6574f41c7a79778be3a8ec 0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if and Standard_RangeError_Raise_if --- diff --git a/src/Standard/Standard_OutOfRange.hxx b/src/Standard/Standard_OutOfRange.hxx index 28b112398e..0d2cf80a95 100644 --- a/src/Standard/Standard_OutOfRange.hxx +++ b/src/Standard/Standard_OutOfRange.hxx @@ -26,8 +26,17 @@ class Standard_OutOfRange; DEFINE_STANDARD_HANDLE(Standard_OutOfRange, Standard_RangeError) #if !defined No_Exception && !defined No_Standard_OutOfRange +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) + // suppress false-positive warnings produced by GCC optimizer + #define Standard_OutOfRange_Raise_if(CONDITION, MESSAGE) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wstrict-overflow\"") \ + if (CONDITION) throw Standard_OutOfRange(MESSAGE); \ + _Pragma("GCC diagnostic pop") +#else #define Standard_OutOfRange_Raise_if(CONDITION, MESSAGE) \ if (CONDITION) throw Standard_OutOfRange(MESSAGE); +#endif #else #define Standard_OutOfRange_Raise_if(CONDITION, MESSAGE) #endif diff --git a/src/Standard/Standard_RangeError.hxx b/src/Standard/Standard_RangeError.hxx index 2cdffec504..52477fb053 100644 --- a/src/Standard/Standard_RangeError.hxx +++ b/src/Standard/Standard_RangeError.hxx @@ -26,8 +26,17 @@ class Standard_RangeError; DEFINE_STANDARD_HANDLE(Standard_RangeError, Standard_DomainError) #if !defined No_Exception && !defined No_Standard_RangeError +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) + // suppress false-positive warnings produced by GCC optimizer + #define Standard_RangeError_Raise_if(CONDITION, MESSAGE) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wstrict-overflow\"") \ + if (CONDITION) throw Standard_RangeError(MESSAGE); \ + _Pragma("GCC diagnostic pop") +#else #define Standard_RangeError_Raise_if(CONDITION, MESSAGE) \ if (CONDITION) throw Standard_RangeError(MESSAGE); +#endif #else #define Standard_RangeError_Raise_if(CONDITION, MESSAGE) #endif