Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Enable Werror for dev builds

Commit
87c125ecb89724afb52f05170e44e3995733066a
Author
Martin Hořeňovský ·
Parents
3b965aa50131

Files · Download .tar.gz

Changes

 CMakeLists.txt                                   | 2 +-
 examples/210-Evt-EventListeners.cpp              | 9 ++++++++-
 include/internal/catch_fatal_condition.cpp       | 9 +++++++++
 projects/SelfTest/UsageTests/Condition.tests.cpp | 5 ++++-
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1208a9a..3792bad6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -302,7 +302,7 @@ if (NOT NO_SELFTEST)
 
     # Add desired warnings
     if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
-        target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code )
+        target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code -Werror )
     endif()
     # Clang specific warning go here
     if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
diff --git a/examples/210-Evt-EventListeners.cpp b/examples/210-Evt-EventListeners.cpp
index a2103a0b..8ba360f5 100644
--- a/examples/210-Evt-EventListeners.cpp
+++ b/examples/210-Evt-EventListeners.cpp
@@ -295,12 +295,15 @@ void print( std::ostream& os, int const level, std::string const& title, Catch::
 // 2. My listener and registration:
 //
 
-const std::string dashed_line =
+char const * dashed_line =
     "--------------------------------------------------------------------------";
 
 struct MyListener : Catch::TestEventListenerBase {
 
     using TestEventListenerBase::TestEventListenerBase; // inherit constructor
+    
+    // Get rid of Wweak-tables
+    ~MyListener();
 
     // The whole test run starting
     virtual void testRunStarting( Catch::TestRunInfo const& testRunInfo ) override {
@@ -367,6 +370,10 @@ struct MyListener : Catch::TestEventListenerBase {
 
 CATCH_REGISTER_LISTENER( MyListener )
 
+// Get rid of Wweak-tables
+MyListener::~MyListener() {}
+
+
 // -----------------------------------------------------------------------
 // 3. Test cases:
 //
diff --git a/include/internal/catch_fatal_condition.cpp b/include/internal/catch_fatal_condition.cpp
index 39b63455..0fa09f26 100644
--- a/include/internal/catch_fatal_condition.cpp
+++ b/include/internal/catch_fatal_condition.cpp
@@ -12,6 +12,11 @@
 #include "catch_context.h"
 #include "catch_interfaces_capture.h"
 
+#if defined(__GNUC__)
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
+
 namespace {
     // Report the error condition
     void reportFatal( char const * const message ) {
@@ -174,3 +179,7 @@ namespace Catch {
 #  endif // CATCH_CONFIG_POSIX_SIGNALS
 
 #endif // not Windows
+
+#if defined(__GNUC__)
+#    pragma GCC diagnostic pop
+#endif
diff --git a/projects/SelfTest/UsageTests/Condition.tests.cpp b/projects/SelfTest/UsageTests/Condition.tests.cpp
index 975fd400..9aed5e2c 100644
--- a/projects/SelfTest/UsageTests/Condition.tests.cpp
+++ b/projects/SelfTest/UsageTests/Condition.tests.cpp
@@ -8,7 +8,10 @@
 #ifdef __clang__
 #   pragma clang diagnostic push
 #   pragma clang diagnostic ignored "-Wpadded"
-#   pragma clang diagnostic ignored "-Wdouble-promotion"
+// Wdouble-promotion is not supported until 3.8
+#   if (__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ > 7)
+#       pragma clang diagnostic ignored "-Wdouble-promotion"
+#   endif    
 #endif
 
 #include "catch.hpp"