]> OCCT Git - occt-copy.git/commitdiff
0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_...
authorkgv <kgv@opencascade.com>
Tue, 6 Nov 2018 13:07:21 +0000 (16:07 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 7 Nov 2018 15:19:45 +0000 (18:19 +0300)
src/Standard/Standard_OutOfRange.hxx
src/Standard/Standard_RangeError.hxx

index 28b112398e0ef957f6d9d741880a85eaa0fa7a12..0d2cf80a95623ce8d7a040bfa942bfdc1cc15ad9 100644 (file)
@@ -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
index 2cdffec50485861c188503117ff4867a1fca6d70..52477fb053ae4ac3e7609124c1f4abc653025b8f 100644 (file)
@@ -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