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
This commit is contained in:
Alecto Irene Perez 2021-10-04 13:11:03 -06:00 committed by GitHub
parent 3d01f3ae32
commit dba29b60d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -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]") {

View File

@ -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 {[<");