Merge branch 'clang-warnings'

Fix some harmless but annoying clang warnings.

See https://github.com/wxWidgets/wxWidgets/pull/1115
This commit is contained in:
Vadim Zeitlin
2019-01-05 23:12:58 +01:00
6 changed files with 20 additions and 6 deletions

View File

@@ -75,13 +75,13 @@ public: \
// the names of the hasher and comparator classes are interpreted as naming
// the base class which is inaccessible.
// The workaround is to prefix the class names with 'struct'; however, don't
// do this on MSVC because it causes a warning there if the class was
// declared as a 'class' rather than a 'struct' (and MSVC's std::unordered_set
// implementation does not suffer from the access problem).
#ifdef _MSC_VER
#define WX_MAYBE_PREFIX_WITH_STRUCT(STRUCTNAME) STRUCTNAME
#else
// do this unconditionally, as with other compilers (both MSVC and clang)
// doing it causes a warning if the class was declared as a 'class' rather than
// a 'struct'.
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
#define WX_MAYBE_PREFIX_WITH_STRUCT(STRUCTNAME) struct STRUCTNAME
#else
#define WX_MAYBE_PREFIX_WITH_STRUCT(STRUCTNAME) STRUCTNAME
#endif
#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, PTROP, CLASSNAME, CLASSEXP ) \

View File

@@ -364,12 +364,18 @@ void ArraysTestCase::wxStringArrayTest()
a6.Add("Foo");
a6.Insert(a6[0], 1, 100);
// The whole point of this code is to test self-assignment, so suppress
// clang warning about it.
wxCLANG_WARNING_SUPPRESS(self-assign-overloaded)
wxArrayString a7;
a7 = a7;
CPPUNIT_ASSERT_EQUAL( 0, a7.size() );
a7.Add("Bar");
a7 = a7;
CPPUNIT_ASSERT_EQUAL( 1, a7.size() );
wxCLANG_WARNING_RESTORE(self-assign-overloaded)
}
void ArraysTestCase::SortedArray()

View File

@@ -135,7 +135,9 @@ void VarArgTestCase::CharPrintf()
#ifdef _MSC_VER
#pragma warning(disable:4309) // truncation of constant value
#endif
wxCLANG_WARNING_SUPPRESS(constant-conversion)
c = 240;
wxCLANG_WARNING_RESTORE(constant-conversion)
#ifdef _MSC_VER
#pragma warning(default:4309)
#endif

View File

@@ -21,6 +21,7 @@
// Suppress some warnings in catch_impl.hpp.
wxCLANG_WARNING_SUPPRESS(missing-braces)
wxCLANG_WARNING_SUPPRESS(logical-op-parentheses)
wxCLANG_WARNING_SUPPRESS(inconsistent-missing-override)
// This file needs to get the CATCH definitions in addition to the usual
// assertion macros declarations from catch.hpp included by testprec.h.
@@ -30,6 +31,7 @@ wxCLANG_WARNING_SUPPRESS(logical-op-parentheses)
wxCLANG_WARNING_RESTORE(missing-braces)
wxCLANG_WARNING_RESTORE(logical-op-parentheses)
wxCLANG_WARNING_RESTORE(inconsistent-missing-override)
// This probably could be done by predefining CLARA_CONFIG_MAIN, but at the
// point where we are, just define this global variable manually.

View File

@@ -123,7 +123,9 @@ void URLTestCase::CopyAndAssignment()
CPPUNIT_ASSERT(url1 == url2);
// assignment to self
wxCLANG_WARNING_SUPPRESS(self-assign-overloaded)
url2 = url2;
wxCLANG_WARNING_RESTORE(self-assign-overloaded)
// check for destructor (with base pointer!)
puri = new wxURL();

View File

@@ -133,7 +133,9 @@ void WeakRefTestCase::DeclareTest()
wxWeakRef<IncompleteClass> p;
// Copying should be also OK
wxCLANG_WARNING_SUPPRESS(self-assign-overloaded)
p = p;
wxCLANG_WARNING_RESTORE(self-assign-overloaded)
// Assigning a raw pointer should cause compile error
#ifdef TEST_INVALID_INCOMPLETE_WEAKREF