From 23b263a6d2e952ce05b65263e0e51e433b10209c Mon Sep 17 00:00:00 2001
From: Steven Hahn <hahnse@ornl.gov>
Date: Mon, 19 Oct 2015 06:54:25 -0400
Subject: [PATCH] Refs #14013. Suppress gcc warnings.

---
 Framework/Geometry/src/Objects/RuleItems.cpp | 19 ++++++++++++++++++
 Framework/Geometry/src/Surfaces/Cone.cpp     | 19 ++++++++++++++++++
 Framework/Geometry/src/Surfaces/Cylinder.cpp | 19 ++++++++++++++++++
 Framework/Geometry/src/Surfaces/Plane.cpp    | 19 ++++++++++++++++++
 Framework/Geometry/src/Surfaces/Sphere.cpp   | 19 ++++++++++++++++++
 Framework/Geometry/src/Surfaces/Surface.cpp  | 21 ++++++++++++++++++++
 Framework/Geometry/src/Surfaces/Torus.cpp    | 21 ++++++++++++++++++++
 7 files changed, 137 insertions(+)

diff --git a/Framework/Geometry/src/Objects/RuleItems.cpp b/Framework/Geometry/src/Objects/RuleItems.cpp
index d70ed361223..30e7042d782 100644
--- a/Framework/Geometry/src/Objects/RuleItems.cpp
+++ b/Framework/Geometry/src/Objects/RuleItems.cpp
@@ -23,10 +23,29 @@
 #include "MantidGeometry/Objects/Object.h"
 
 #ifdef ENABLE_OPENCASCADE
+// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
+// used.
+// Undefine it here before we include the headers to avoid a warning
+#ifdef _MSC_VER
+#undef _USE_MATH_DEFINES
+#ifdef M_SQRT1_2
+#undef M_SQRT1_2
+#endif
+#endif
+
+#include "MantidKernel/WarningSuppressions.h"
+GCC_DIAG_OFF(conversion)
+// clang-format off
+GCC_DIAG_OFF(cast-qual)
+// clang-format on
 #include <TopoDS_Shape.hxx>
 #include <BRepAlgoAPI_Common.hxx>
 #include <BRepAlgoAPI_Fuse.hxx>
 #include <BRepPrimAPI_MakeBox.hxx>
+GCC_DIAG_ON(conversion)
+// clang-format off
+GCC_DIAG_ON(cast-qual)
+// clang-format on
 #endif
 
 namespace Mantid {
diff --git a/Framework/Geometry/src/Surfaces/Cone.cpp b/Framework/Geometry/src/Surfaces/Cone.cpp
index 3cec701e952..834ba4ca109 100644
--- a/Framework/Geometry/src/Surfaces/Cone.cpp
+++ b/Framework/Geometry/src/Surfaces/Cone.cpp
@@ -20,7 +20,26 @@
 #include "MantidGeometry/Surfaces/Cone.h"
 
 #ifdef ENABLE_OPENCASCADE
+// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
+// used.
+// Undefine it here before we include the headers to avoid a warning
+#ifdef _MSC_VER
+#undef _USE_MATH_DEFINES
+#ifdef M_SQRT1_2
+#undef M_SQRT1_2
+#endif
+#endif
+
+#include "MantidKernel/WarningSuppressions.h"
+GCC_DIAG_OFF(conversion)
+// clang-format off
+GCC_DIAG_OFF(cast-qual)
+// clang-format on
 #include <BRepPrimAPI_MakeCone.hxx>
+GCC_DIAG_ON(conversion)
+// clang-format off
+GCC_DIAG_ON(cast-qual)
+// clang-format on
 #endif
 
 namespace Mantid {
diff --git a/Framework/Geometry/src/Surfaces/Cylinder.cpp b/Framework/Geometry/src/Surfaces/Cylinder.cpp
index a3586c0bf78..d59a3e83fde 100644
--- a/Framework/Geometry/src/Surfaces/Cylinder.cpp
+++ b/Framework/Geometry/src/Surfaces/Cylinder.cpp
@@ -6,7 +6,26 @@
 #include <iostream>
 
 #ifdef ENABLE_OPENCASCADE
+// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
+// used.
+// Undefine it here before we include the headers to avoid a warning
+#ifdef _MSC_VER
+#undef _USE_MATH_DEFINES
+#ifdef M_SQRT1_2
+#undef M_SQRT1_2
+#endif
+#endif
+
+#include "MantidKernel/WarningSuppressions.h"
+GCC_DIAG_OFF(conversion)
+// clang-format off
+GCC_DIAG_OFF(cast-qual)
+// clang-format on
 #include <BRepPrimAPI_MakeCylinder.hxx>
+GCC_DIAG_ON(conversion)
+// clang-format off
+GCC_DIAG_ON(cast-qual)
+// clang-format on
 #endif
 
 namespace Mantid {
diff --git a/Framework/Geometry/src/Surfaces/Plane.cpp b/Framework/Geometry/src/Surfaces/Plane.cpp
index 7c72edd28f7..eb5f0bba0fa 100644
--- a/Framework/Geometry/src/Surfaces/Plane.cpp
+++ b/Framework/Geometry/src/Surfaces/Plane.cpp
@@ -6,11 +6,30 @@
 #include <iostream>
 
 #ifdef ENABLE_OPENCASCADE
+// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
+// used.
+// Undefine it here before we include the headers to avoid a warning
+#ifdef _MSC_VER
+#undef _USE_MATH_DEFINES
+#ifdef M_SQRT1_2
+#undef M_SQRT1_2
+#endif
+#endif
+
+#include "MantidKernel/WarningSuppressions.h"
+GCC_DIAG_OFF(conversion)
+// clang-format off
+GCC_DIAG_OFF(cast-qual)
+// clang-format on
 #include <BRepPrimAPI_MakeBox.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepPrimAPI_MakeHalfSpace.hxx>
 #include <BRepAlgoAPI_Common.hxx>
 #include <gp_Pln.hxx>
+GCC_DIAG_ON(conversion)
+// clang-format off
+GCC_DIAG_ON(cast-qual)
+// clang-format on
 #endif
 
 namespace Mantid {
diff --git a/Framework/Geometry/src/Surfaces/Sphere.cpp b/Framework/Geometry/src/Surfaces/Sphere.cpp
index 23368646a58..8daa621e6bb 100644
--- a/Framework/Geometry/src/Surfaces/Sphere.cpp
+++ b/Framework/Geometry/src/Surfaces/Sphere.cpp
@@ -3,7 +3,26 @@
 #include "MantidKernel/Tolerance.h"
 
 #ifdef ENABLE_OPENCASCADE
+// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
+// used.
+// Undefine it here before we include the headers to avoid a warning
+#ifdef _MSC_VER
+#undef _USE_MATH_DEFINES
+#ifdef M_SQRT1_2
+#undef M_SQRT1_2
+#endif
+#endif
+
+#include "MantidKernel/WarningSuppressions.h"
+GCC_DIAG_OFF(conversion)
+// clang-format off
+GCC_DIAG_OFF(cast-qual)
+// clang-format on
 #include <BRepPrimAPI_MakeSphere.hxx>
+GCC_DIAG_ON(conversion)
+// clang-format off
+GCC_DIAG_ON(cast-qual)
+// clang-format on
 #endif
 
 namespace Mantid {
diff --git a/Framework/Geometry/src/Surfaces/Surface.cpp b/Framework/Geometry/src/Surfaces/Surface.cpp
index 664c8c61751..adfb25b6e32 100644
--- a/Framework/Geometry/src/Surfaces/Surface.cpp
+++ b/Framework/Geometry/src/Surfaces/Surface.cpp
@@ -19,9 +19,30 @@
 #include "MantidGeometry/Math/PolyBase.h"
 #include "MantidGeometry/Surfaces/BaseVisit.h"
 #include "MantidGeometry/Surfaces/Surface.h"
+
 #ifdef ENABLE_OPENCASCADE
+// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
+// used.
+// Undefine it here before we include the headers to avoid a warning
+#ifdef _MSC_VER
+#undef _USE_MATH_DEFINES
+#ifdef M_SQRT1_2
+#undef M_SQRT1_2
+#endif
+#endif
+
+#include "MantidKernel/WarningSuppressions.h"
+GCC_DIAG_OFF(conversion)
+// clang-format off
+GCC_DIAG_OFF(cast-qual)
+// clang-format on
 #include <TopoDS_Shape.hxx>
+GCC_DIAG_ON(conversion)
+// clang-format off
+GCC_DIAG_ON(cast-qual)
+// clang-format on
 #endif
+
 namespace Mantid {
 
 namespace Geometry {
diff --git a/Framework/Geometry/src/Surfaces/Torus.cpp b/Framework/Geometry/src/Surfaces/Torus.cpp
index 4fed5241d7b..0f3a8ebdaaf 100644
--- a/Framework/Geometry/src/Surfaces/Torus.cpp
+++ b/Framework/Geometry/src/Surfaces/Torus.cpp
@@ -17,9 +17,30 @@
 #include "MantidGeometry/Surfaces/BaseVisit.h"
 #include "MantidGeometry/Surfaces/Surface.h"
 #include "MantidGeometry/Surfaces/Torus.h"
+
 #ifdef ENABLE_OPENCASCADE
+// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
+// used.
+// Undefine it here before we include the headers to avoid a warning
+#ifdef _MSC_VER
+#undef _USE_MATH_DEFINES
+#ifdef M_SQRT1_2
+#undef M_SQRT1_2
+#endif
+#endif
+
+#include "MantidKernel/WarningSuppressions.h"
+GCC_DIAG_OFF(conversion)
+// clang-format off
+GCC_DIAG_OFF(cast-qual)
+// clang-format on
 #include <TopoDS_Shape.hxx>
+GCC_DIAG_ON(conversion)
+// clang-format off
+GCC_DIAG_ON(cast-qual)
+// clang-format on
 #endif
+
 namespace Mantid {
 
 namespace Geometry {
-- 
GitLab