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

Fixed #2272: Compilation failure with C++20 (#2297)

* Suppressed warning for comma-in-indexing-operator in tests that check
  that specific behaviour.
* Made deprecated (and removed) allocator usings conditional on the tests
  being compiled with old version of MSVC that still requires them.

Fixes #2272
Commit
dba29b60d639bf8d206a9a12c223e6ed4284fb13
Author
Alecto Irene Perez ·
Committer
GitHub
Parents
3d01f3ae3279

Files · Download .tar.gz

Changes

 projects/SelfTest/UsageTests/Matchers.tests.cpp |  6 ++++--
 projects/SelfTest/UsageTests/Message.tests.cpp  | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/projects/SelfTest/UsageTests/Matchers.tests.cpp b/projects/SelfTest/UsageTests/Matchers.tests.cpp
index 1797d4a1..3fc64b96 100644
--- a/projects/SelfTest/UsageTests/Matchers.tests.cpp
+++ b/projects/SelfTest/UsageTests/Matchers.tests.cpp
@@ -242,12 +242,14 @@ namespace { namespace MatchersTests {
 
             ~CustomAllocator() = default;
 
+#if defined(_MSC_VER) && _MSVC_LANG < 201703L
             using std::allocator<T>::address;
-            using std::allocator<T>::allocate;
             using std::allocator<T>::construct;
-            using std::allocator<T>::deallocate;
             using std::allocator<T>::max_size;
             using std::allocator<T>::destroy;
+#endif
+            using std::allocator<T>::allocate;
+            using std::allocator<T>::deallocate;
         };
 
         TEST_CASE("Vector matchers", "[matchers][vector]") {
diff --git a/projects/SelfTest/UsageTests/Message.tests.cpp b/projects/SelfTest/UsageTests/Message.tests.cpp
index 93347084..d151b2ba 100644
--- a/projects/SelfTest/UsageTests/Message.tests.cpp
+++ b/projects/SelfTest/UsageTests/Message.tests.cpp
@@ -241,6 +241,17 @@ std::ostream& operator<<(std::ostream& out, helper_1436<T1, T2> const& helper) {
     return out;
 }
 
+// Clang and gcc have different names for this warning, and clang also
+// warns about an unused value
+#if defined(__GNUG__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcomma-subscript"
+#elif defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-comma-subscript"
+#pragma clang diagnostic ignored "-Wunused-value"
+#endif
+
 TEST_CASE("CAPTURE can deal with complex expressions involving commas", "[messages][capture]") {
     CAPTURE(std::vector<int>{1, 2, 3}[0, 1, 2],
             std::vector<int>{1, 2, 3}[(0, 1)],
@@ -251,6 +262,10 @@ TEST_CASE("CAPTURE can deal with complex expressions involving commas", "[messag
     SUCCEED();
 }
 
+#ifdef __GNUG__
+#pragma GCC diagnostic pop
+#endif
+
 TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]") {
     CAPTURE(("comma, in string", "escaped, \", "), "single quote in string,',", "some escapes, \\,\\\\");
     CAPTURE("some, ), unmatched, } prenheses {[<");