Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlecto Irene Perez2021-10-21 07:47:21 -0600
committerGitHub2021-10-21 15:47:21 +0200
commit06cf2a4724d74af88c0a4a9a7445424cc831afd6 (patch)
tree38ee8485582b73c5cf496183d0aece998816e991
parent4436a604566f18091489b55af215b8d32afe657a (diff)
downloadcatch3-06cf2a4724d74af88c0a4a9a7445424cc831afd6.tar.gz
Apply PR #2297 to devel branch (#2300)
* 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>
-rw-r--r--tests/SelfTest/UsageTests/Message.tests.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp
index a30c2e9e..97ac4abd 100644
--- a/tests/SelfTest/UsageTests/Message.tests.cpp
+++ b/tests/SelfTest/UsageTests/Message.tests.cpp
@@ -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 {[<");