Commit a2faeda2 authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Update all clang & gcc warnings to macros

parent 6aeec190
......@@ -37,7 +37,7 @@ namespace {
// -----------------------------------------------------------------------------
class MockRNG final : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(nextValue, double());
MOCK_METHOD2(nextValue, double(double, double));
MOCK_METHOD2(nextInt, int(int, int));
......@@ -48,7 +48,7 @@ public:
MOCK_METHOD2(setRange, void(const double, const double));
MOCK_CONST_METHOD0(min, double());
MOCK_CONST_METHOD0(max, double());
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
std::unique_ptr<MeshObject> createCube(const double size, const V3D &centre) {
......
......@@ -23,7 +23,7 @@ using boost::regex;
namespace {
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
/*------------------------------------------------------------
Mock Peak Transform
......@@ -121,5 +121,5 @@ public:
MOCK_CONST_METHOD0(getPeakShape, const Mantid::Geometry::PeakShape &());
};
}
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
#endif /* MANTIDGEOMETRYTEST_MOCKOBJECTS_H_ */
......@@ -23,12 +23,12 @@ private:
enum { value = I };
public:
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
MOCK_CONST_METHOD0(createDefaultTransform, PeakTransform_sptr());
MOCK_CONST_METHOD2(createTransform,
PeakTransform_sptr(const std::string &,
const std::string &));
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
using MockPeakTransformFactory = MockPeakTransformFactoryType<0>;
......
......@@ -21,7 +21,7 @@ namespace {
// -----------------------------------------------------------------------------
class MockRNG final : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(nextValue, double());
MOCK_METHOD2(nextValue, double(double, double));
MOCK_METHOD2(nextInt, int(int, int));
......@@ -32,7 +32,7 @@ public:
MOCK_METHOD2(setRange, void(const double, const double));
MOCK_CONST_METHOD0(min, double());
MOCK_CONST_METHOD0(max, double());
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
}
......
......@@ -398,9 +398,9 @@ private:
MockSpaceGroupGenerator(size_t number, const std::string &hmSymbol,
const std::string &generatorInformation)
: AbstractSpaceGroupGenerator(number, hmSymbol, generatorInformation) {}
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
MOCK_CONST_METHOD0(generateGroup, Group_const_sptr());
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
/* Testing TransformationSpaceGroupGenerator is a bit hard in the sense that
......
......@@ -99,11 +99,11 @@ private:
*/
class MockStructureFactorCalculator : public StructureFactorCalculator {
public:
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
MOCK_CONST_METHOD1(getF, StructureFactor(const V3D &hkl));
MOCK_METHOD1(crystalStructureSetHook,
void(const CrystalStructure &crystalStructure));
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
};
......
......@@ -396,12 +396,12 @@ private:
class TestableSymmetryElementWithAxisGenerator
: public SymmetryElementWithAxisGenerator {
friend class SymmetryElementFactoryTest;
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
MOCK_CONST_METHOD1(generateElement,
SymmetryElement_sptr(const SymmetryOperation &));
MOCK_CONST_METHOD1(canProcess, bool(const SymmetryOperation &));
MOCK_CONST_METHOD1(determineSymbol, std::string(const SymmetryOperation &));
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
class TestableSymmetryElementRotationGenerator
......
......@@ -159,7 +159,7 @@ public:
private:
class MockSymmetryElement : public SymmetryElement {
friend class SymmetryElementTest;
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
public:
MockSymmetryElement(const std::string &hmSymbol)
: SymmetryElement(hmSymbol) {}
......@@ -175,7 +175,7 @@ private:
: SymmetryElementWithAxis(symbol, axis, translation) {}
MOCK_CONST_METHOD0(clone, SymmetryElement_sptr());
};
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
#endif /* MANTID_GEOMETRY_SYMMETRYELEMENTTEST_H_ */
#if GCC_VERSION >= 40800 // 4.8.0
// clang-format off
GCC_DIAG_OFF(literal-suffix)
DIAG_OFF(literal-suffix)
// clang-format on
#endif
#include "MantidICat/CatalogSearch.h"
#if GCC_VERSION >= 40800 // 4.8.0
// clang-format off
GCC_DIAG_ON(literal-suffix)
DIAG_ON(literal-suffix)
// clang-format on
#endif
......
......@@ -5,16 +5,16 @@
// it is automatically generated code
//------------------------------------------------------------------------------
// clang-format off
GCC_DIAG_OFF(cast-qual)
GCC_DIAG_OFF(conversion)
GCC_DIAG_OFF(unused-parameter)
GCC_DIAG_OFF(strict-aliasing)
DIAG_OFF(cast-qual)
DIAG_OFF(conversion)
DIAG_OFF(unused-parameter)
DIAG_OFF(strict-aliasing)
DIAG_OFF(format)
DIAG_OFF(vla)
// clang-format on
GCC_DIAG_OFF(format)
GCC_DIAG_OFF(vla)
#if GCC_VERSION >= 40800 // 4.8.0
// clang-format off
GCC_DIAG_OFF(literal-suffix)
DIAG_OFF(literal-suffix)
// clang-format on
#endif
#ifdef _WIN32
......
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-align"
#endif
 
#include "MantidKernel/WarningSuppressions.h"
// ignore warnings in gSOAP
// Long-term solution is to use gSOAP as an external library or external
// project. see issue #19433
// clang-format off
#if defined(__GNUC__) && __GNUC__ >= 7
GCC_DIAG_OFF(deprecated-declarations)
GCC_DIAG_OFF(format-overflow)
GCC_DIAG_OFF(format-truncation)
GCC_DIAG_OFF(implicit-fallthrough)
#endif
DIAG_OFF(deprecated-declarations)
DIAG_OFF(format-overflow)
DIAG_OFF(format-truncation)
DIAG_OFF(implicit-fallthrough)
DIAG_OFF(cast-align)
// clang-format on
 
/*
......@@ -17022,14 +17017,9 @@ soap::~soap() {
/******************************************************************************/
 
// clang-format off
#if defined(__GNUC__) && __GNUC__ >= 7
GCC_DIAG_ON(deprecated-declarations)
GCC_DIAG_ON(format-overflow)
GCC_DIAG_ON(format-truncation)
GCC_DIAG_ON(implicit-fallthrough)
#endif
DIAG_ON(deprecated-declarations)
DIAG_ON(format-overflow)
DIAG_ON(format-truncation)
DIAG_ON(implicit-fallthrough)
DIAG_ON(cast-align)
// clang-format on
#ifdef __clang__
#pragma clang diagnostic pop
#endif
......@@ -5,16 +5,16 @@
// it is automatically generated code
//------------------------------------------------------------------------------
// clang-format off
GCC_DIAG_OFF(cast-qual)
GCC_DIAG_OFF(conversion)
GCC_DIAG_OFF(unused-parameter)
GCC_DIAG_OFF(strict-aliasing)
DIAG_OFF(cast-qual)
DIAG_OFF(conversion)
DIAG_OFF(unused-parameter)
DIAG_OFF(strict-aliasing)
DIAG_OFF(format)
DIAG_OFF(vla)
// clang-format on
GCC_DIAG_OFF(format)
GCC_DIAG_OFF(vla)
#if GCC_VERSION >= 40800 // 4.8.0
// clang-format off
GCC_DIAG_OFF(literal-suffix)
DIAG_OFF(literal-suffix)
// clang-format on
#endif
#ifdef _WIN32
......
......@@ -3,7 +3,7 @@
#include "MantidAPI/WorkspaceFactory.h"
#if GCC_VERSION >= 40800 // 4.8.0
// clang-format off
GCC_DIAG_OFF(literal-suffix)
DIAG_OFF(literal-suffix)
// clang-format on
#endif
#include "MantidICat/ICat3/ICat3Helper.h"
......
......@@ -5,16 +5,16 @@
// it is automatically generated code
//------------------------------------------------------------------------------
// clang-format off
GCC_DIAG_OFF(cast-qual)
GCC_DIAG_OFF(conversion)
GCC_DIAG_OFF(unused-parameter)
GCC_DIAG_OFF(strict-aliasing)
DIAG_OFF(cast-qual)
DIAG_OFF(conversion)
DIAG_OFF(unused-parameter)
DIAG_OFF(strict-aliasing)
DIAG_OFF(format)
DIAG_OFF(vla)
// clang-format on
GCC_DIAG_OFF(format)
GCC_DIAG_OFF(vla)
#if GCC_VERSION >= 40800 // 4.8.0
// clang-format off
GCC_DIAG_OFF(literal-suffix)
DIAG_OFF(literal-suffix)
// clang-format on
#endif
#ifdef _WIN32
......
......@@ -124,14 +124,8 @@ std::string toPrettyString(
}
return Strings::shorten(retVal, maxLength);
}
// AppleClang gives warning if the result is unused.
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
// clang-format off
GCC_DIAG_OFF(unused-function)
DIAG_OFF(unused-function)
// clang-format on
/** Explicit specialization for a property of type std::vector<bool>.
* This will catch Vectors of char, double, float etc.
......@@ -148,11 +142,8 @@ std::string toPrettyString(
maxLength);
}
// clang-format off
GCC_DIAG_ON(unused-function)
DIAG_ON(unused-function)
// clang-format on
#if __clang__
#pragma clang diagnostic pop
#endif
/// Specialization for a property of type std::vector<std::vector>.
template <typename T>
......
......@@ -76,30 +76,34 @@
// define macros for turning the warning suppression on/off for GCC
// note that we turn off unknown warnings here as well so that we can use the
// same macro for GCC and clang.
// clang-format off
#if GCC_VERSION >= 40600 // GCC 4.6.0
#define DIAG_OFF(x) \
DIAG_PRAGMA(push) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning)) \
#define DIAG_OFF(x) \
DIAG_PRAGMA(push) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning)) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, x))
#define DIAG_ON(x) DIAG_PRAGMA(pop)
#else
#define DIAG_OFF(x) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning)) \
#define DIAG_OFF(x) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning)) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, x))
#define DIAG_ON(x) \
DIAG_PRAGMA(warning DIAG_JOINSTR(-W, unknown-warning)) \
DIAG_PRAGMA(warning DIAG_JOINSTR(-W, x))
#define DIAG_ON(x) \
DIAG_PRAGMA(warning DIAG_JOINSTR(-W, unknown-warning)) \
DIAG_PRAGMA(warning DIAG_JOINSTR(-W, x))
#endif
// clang-format on
#elif defined(CLANG_VERSION) && CLANG_VERSION >= 306
// define macros for turning the warning suppression on/off for clang
// note that we turn off unknown warnings here as well so that we can use the
// same macro for GCC and clang.
#define DIAG_OFF(x) \
DIAG_PRAGMA(push) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning-option)) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, x))
// clang-format off
#define DIAG_OFF(x) \
DIAG_PRAGMA(push) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning-option)) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, x))
#define DIAG_ON(x) DIAG_PRAGMA(pop)
// clang-format on
#else
// neither clang or GCC
#define DIAG_OFF(x)
......@@ -108,7 +112,6 @@
#endif
// Defining this macro separately since clang-tidy tries to add spaces around
// the hyphen and we use it in a lot of test files.
// clang-format off
......@@ -124,10 +127,10 @@
#endif
// clang-format on
#ifdef GCC_VERSION
#define GCC_UNUSED_FUNCTION __attribute__((unused))
#if defined(GCC_VERSION) || defined(CLANG_VERSION)
#define UNUSED_FUNCTION __attribute__((unused))
#else
#define GCC_UNUSED_FUNCTION
#define UNUSED_FUNCTION
#endif
#endif /*MANTID_KERNEL_WARNINGSUPPRESSIONS_H_*/
......@@ -171,9 +171,7 @@ public:
};
// clang-format off
#if !defined(__clang__)
GCC_DIAG_OFF(maybe-uninitialized)
#endif
DIAG_OFF(maybe-uninitialized)
// clang-format on
template <class _RealType>
template <class _URNG>
......@@ -201,9 +199,7 @@ _RealType normal_distribution<_RealType>::operator()(_URNG &__g,
return _Up * __p.stddev() + __p.mean();
}
// clang-format off
#if !defined(__clang__)
GCC_DIAG_ON(maybe-uninitialized)
#endif
DIAG_ON(maybe-uninitialized)
// clang-format on
template <class _CharT, class _Traits, class _RT>
......
......@@ -14,7 +14,7 @@ using namespace testing;
/**
* Helper Mock MDUnit
*/
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
class MockMDUnit : public MDUnit {
public:
MOCK_CONST_METHOD0(getUnitLabel, UnitLabel());
......@@ -31,7 +31,7 @@ public:
MOCK_CONST_METHOD1(createRaw, MDUnit *(const std::string &));
MOCK_CONST_METHOD1(canInterpret, bool(const std::string &));
};
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
class MDUnitFactoryTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
......
......@@ -17,12 +17,12 @@ private:
public:
Mock3DRandomNumberGenerator()
: Mantid::Kernel::NDRandomNumberGenerator(3) {}
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(generateNextPoint, void());
MOCK_METHOD0(restart, void());
MOCK_METHOD0(save, void());
MOCK_METHOD0(restore, void());
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
};
public:
......
......@@ -19,7 +19,7 @@ operator<<(std::basic_ostream<CharType, CharTrait> &out,
return out;
}
}
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE
using namespace Mantid::Kernel;
class MockCatalogConfigService : public CatalogConfigService {
public:
......@@ -37,7 +37,7 @@ public:
MOCK_CONST_METHOD0(linuxPrefix, const std::string());
MOCK_CONST_METHOD0(clone, ICatalogInfo *());
};
GCC_DIAG_ON_SUGGEST_OVERRIDE
DIAG_ON_SUGGEST_OVERRIDE
// Adaptee
struct UserType {
std::string getString(const std::string &) const { return "my_value"; }
......
Supports Markdown
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