From a0ece7b2528418c730c4feb2871808f739afd482 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Tue, 7 Jun 2022 18:46:46 +0200 Subject: [PATCH] Compatility fixes for GCC5 (#2448) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * GCC5 compat: work around inherited constructor issues Don't use inherited constructors, forward manually instead. This basically reverts 61f803126d3cff2195d700d11d07c6578f416b23. I believe that GCC5 does not implement P0136, a C++17 change that made inherited constructors actually usable and was backported as a DR all the way to C++11. * GCC5 compat: bypass std::pair construction issue Co-authored-by: Martin Hořeňovský --- src/catch2/internal/catch_reporter_spec_parser.cpp | 2 +- src/catch2/reporters/catch_reporter_automake.hpp | 8 +++++++- src/catch2/reporters/catch_reporter_cumulative_base.hpp | 8 +++++++- src/catch2/reporters/catch_reporter_streaming_base.hpp | 8 +++++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/catch2/internal/catch_reporter_spec_parser.cpp b/src/catch2/internal/catch_reporter_spec_parser.cpp index 28b2088ac4..30ee191c59 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.cpp +++ b/src/catch2/internal/catch_reporter_spec_parser.cpp @@ -126,7 +126,7 @@ namespace Catch { return {}; } - auto ret = kvPairs.emplace( kv.key, kv.value ); + auto ret = kvPairs.emplace( std::string(kv.key), std::string(kv.value) ); if ( !ret.second ) { // Duplicated key. We might want to handle this differently, // e.g. by overwriting the existing value? diff --git a/src/catch2/reporters/catch_reporter_automake.hpp b/src/catch2/reporters/catch_reporter_automake.hpp index cd85e6bfcc..bf18fddf7d 100644 --- a/src/catch2/reporters/catch_reporter_automake.hpp +++ b/src/catch2/reporters/catch_reporter_automake.hpp @@ -8,7 +8,9 @@ #ifndef CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED #define CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED +#include #include +#include #include @@ -16,7 +18,11 @@ namespace Catch { class AutomakeReporter final : public StreamingReporterBase { public: - using StreamingReporterBase::StreamingReporterBase; + // GCC5 compat: we cannot use inherited constructor, because it + // doesn't implement backport of P0136 + AutomakeReporter(ReporterConfig&& _config): + StreamingReporterBase(CATCH_MOVE(_config)) + {} ~AutomakeReporter() override; static std::string getDescription() { diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp index 742eaac979..c4dcdae036 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -8,7 +8,9 @@ #ifndef CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED #define CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED +#include #include +#include #include #include @@ -88,7 +90,11 @@ namespace Catch { using TestCaseNode = Node; using TestRunNode = Node; - using ReporterBase::ReporterBase; + // GCC5 compat: we cannot use inherited constructor, because it + // doesn't implement backport of P0136 + CumulativeReporterBase(ReporterConfig&& _config): + ReporterBase(CATCH_MOVE(_config)) + {} ~CumulativeReporterBase() override; void benchmarkPreparing( StringRef ) override {} diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp index 5088bd0b77..76788d8d5c 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -8,7 +8,9 @@ #ifndef CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED #define CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED +#include #include +#include #include @@ -16,7 +18,11 @@ namespace Catch { class StreamingReporterBase : public ReporterBase { public: - using ReporterBase::ReporterBase; + // GCC5 compat: we cannot use inherited constructor, because it + // doesn't implement backport of P0136 + StreamingReporterBase(ReporterConfig&& _config): + ReporterBase(CATCH_MOVE(_config)) + {} ~StreamingReporterBase() override; void benchmarkPreparing( StringRef ) override {}