Sweep out some extra warnings

Swept:
`-Wpadded` in some places (where it caused extra size, instead of just
saying "hey, we padded struct at the end to align, just as standard says")
`-Wweak-vtables` everywhere (Clang)
`-Wexit-time-destructors` everywhere (Clang)
`-Wmissing-noreturn` everywhere (Clang)

The last three are enabled for Clang compilation going forward.

Also enabled `-Wunreachable-code` for Clang and GCC
This commit is contained in:
Martin Hořeňovský
2017-09-07 16:51:33 +02:00
parent 6105282c4f
commit 9aa96712ae
61 changed files with 319 additions and 182 deletions

View File

@@ -1003,6 +1003,6 @@ with expansion:
"{?}" == "1"
===============================================================================
test cases: 177 | 126 passed | 47 failed | 4 failed as expected
test cases: 176 | 125 passed | 47 failed | 4 failed as expected
assertions: 878 | 761 passed | 96 failed | 21 failed as expected

View File

@@ -7434,6 +7434,6 @@ MiscTests.cpp:<line number>:
PASSED:
===============================================================================
test cases: 177 | 124 passed | 49 failed | 4 failed as expected
test cases: 176 | 123 passed | 49 failed | 4 failed as expected
assertions: 877 | 757 passed | 99 failed | 21 failed as expected

View File

@@ -6946,9 +6946,6 @@ Message from section two
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="assertions with commas are allowed" filename="projects/<exe-name>/TrickyTests.cpp" >
<OverallResult success="true"/>
</TestCase>
<TestCase name="atomic if" tags="[0][failing]" filename="projects/<exe-name>/MiscTests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MiscTests.cpp" >
<Original>

View File

@@ -6,7 +6,9 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wdouble-promotion"
#endif
#include "catch.hpp"
@@ -161,6 +163,11 @@ TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" )
CHECK( data.str_hello <= "a" );
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
// Comparisons with int literals
TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned" )
{

View File

@@ -14,6 +14,10 @@
#ifdef _MSC_VER
#pragma warning(disable:4702) // Unreachable code -- MSVC 19 (VS 2015) sees right through the indirection
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wweak-vtables"
#endif
namespace
{
@@ -219,3 +223,7 @@ TEST_CASE( "#748 - captures with unexpected exceptions", "[.][failing][!throws][
REQUIRE_THROWS( thisThrows() );
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif

View File

@@ -8,6 +8,12 @@
#include "catch.hpp"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wweak-vtables"
#pragma clang diagnostic ignored "-Wpadded"
#endif
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
inline const char* testStringForMatching()
@@ -166,16 +172,18 @@ TEST_CASE( "Vector matchers that fail", "[matchers][vector][.][failing]" ) {
#include <exception>
struct SpecialException : std::exception {
SpecialException(int i):i(i) {}
SpecialException(int i_):i(i_) {}
int i;
};
void doesNotThrow() {}
[[noreturn]]
void throws(int i) {
throw SpecialException{ i };
}
[[noreturn]]
void throwsAsInt(int i) {
throw i;
}
@@ -217,3 +225,7 @@ TEST_CASE("Exception matchers that fail", "[matchers][exceptions][!throws][.fail
}
#endif // CATCH_CONFIG_DISABLE_MATCHERS
#ifdef __clang__
#pragma clang diagnostic pop
#endif

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_capture.h"

View File

@@ -1,2 +0,0 @@
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_config.h"

View File

@@ -1,2 +0,0 @@
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_exception.h"

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_registry_hub.h"

View File

@@ -1 +0,0 @@
#include "internal/catch_interfaces_runner.h"

View File

@@ -1,2 +0,0 @@
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_testcase.h"

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_streambuf.h"

View File

@@ -265,4 +265,4 @@ struct AutoTestReg {
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered" );
}
};
AutoTestReg autoTestReg;
static AutoTestReg autoTestReg;

View File

@@ -381,12 +381,9 @@ TEST_CASE( "has printf" ) {
printf( "loose text artifact\n" );
}
TEST_CASE( "assertions with commas are allowed" ) {
}
namespace {
struct constructor_throws {
constructor_throws() {
[[noreturn]] constructor_throws() {
throw 1;
}
};