mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
* Apply PR #2297 to devel branch It turns out that Issue #2272 partially affected the devel branch. When building tests with C++20, the compiler emits a warning that top-level comma expressions in array subscripts are depricated. Warnings are treated as errors, so this caused the build to fail. This commit adds localized warning suppression in accordance with this recommendation here: https://github.com/catchorg/Catch2/pull/2297#discussion_r720848392 Signed-off-by: Alecto Irene Perez <perez.cs@pm.me> * Fixed unknown pragma warning on old versions of gcc & clang This commit fixes an unkwown pragma warning on older versions of GCC and Clang. These older versions don't have a warning for depricated use of the comma subscript. Because warning suppression is localized, and only refers to the comma subscript warning, it doesn't affect compiler warnings in other parts of the code. Signed-off-by: Alecto Irene Perez <perez.cs@pm.me> * More #warning backwards compatibility fixes Signed-off-by: Alecto Irene Perez <perez.cs@pm.me>
This commit is contained in:
parent
4436a60456
commit
06cf2a4724
@ -238,6 +238,20 @@ 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. This warning must be disabled for C++20.
|
||||
#if defined(__GNUG__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
#pragma GCC diagnostic ignored "-Wcomma-subscript"
|
||||
#elif defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#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)],
|
||||
@ -248,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 {[<");
|
||||
|
Loading…
Reference in New Issue
Block a user