From 037bed5b3c06d4254ebaf87dea5d7594290a08c8 Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Tue, 8 Aug 2023 16:55:07 -0500 Subject: [PATCH] testrunner: fix clang compile error related to `dinit` (#5297) This fixes the compile error introduced in 5d201c4. --- test/helpers.h | 19 +++++++++---------- test/testprocessexecutor.cpp | 4 ++-- test/testsingleexecutor.cpp | 4 ++-- test/testthreadexecutor.cpp | 4 ++-- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/test/helpers.h b/test/helpers.h index 9699d6b1f..113668141 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -106,17 +106,16 @@ public: #define dinit(T, ...) \ ([&] { T ${}; __VA_ARGS__; return $; }()) -#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__) -// work around Clang compilation error +// Default construct object to avoid bug in clang // error: default member initializer for 'y' needed within definition of enclosing class 'X' outside of member functions -// work around GCC compilation error -// error: default member initializer for ‘x::y::z’ required before the end of its enclosing class // see https://stackoverflow.com/questions/53408962 -#define DINIT_NOEXCEPT noexcept -#else -// work around GCC 4.8 compilation error -// error: function 'x()' defaulted on its first declaration with an exception-specification that differs from the implicit declaration 'x()' -#define DINIT_NOEXCEPT -#endif +struct make_default_obj +{ + template + operator T() const // NOLINT + { + return T{}; + } +}; #endif // helpersH diff --git a/test/testprocessexecutor.cpp b/test/testprocessexecutor.cpp index ecf9a5f07..bda5f0a3c 100644 --- a/test/testprocessexecutor.cpp +++ b/test/testprocessexecutor.cpp @@ -48,7 +48,7 @@ private: struct CheckOptions { - CheckOptions() DINIT_NOEXCEPT = default; + CheckOptions() = default; SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE; const char* plistOutput = nullptr; std::vector filesList; @@ -58,7 +58,7 @@ private: * Execute check using n jobs for y files which are have * identical data, given within data. */ - void check(unsigned int jobs, int files, int result, const std::string &data, const CheckOptions &opt = {}) { + void check(unsigned int jobs, int files, int result, const std::string &data, const CheckOptions& opt = make_default_obj{}) { errout.str(""); output.str(""); diff --git a/test/testsingleexecutor.cpp b/test/testsingleexecutor.cpp index 56e5e8478..f80530f82 100644 --- a/test/testsingleexecutor.cpp +++ b/test/testsingleexecutor.cpp @@ -63,7 +63,7 @@ private: struct CheckOptions { - CheckOptions() DINIT_NOEXCEPT = default; + CheckOptions() = default; SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE; const char* plistOutput = nullptr; std::vector filesList; @@ -72,7 +72,7 @@ private: std::vector args; }; - void check(int files, int result, const std::string &data, const CheckOptions &opt = {}) { + void check(int files, int result, const std::string &data, const CheckOptions& opt = make_default_obj{}) { errout.str(""); output.str(""); settings.project.fileSettings.clear(); diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index 08cfccfda..e05eff6d5 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -48,7 +48,7 @@ private: struct CheckOptions { - CheckOptions() DINIT_NOEXCEPT = default; + CheckOptions() = default; SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE; const char* plistOutput = nullptr; std::vector filesList; @@ -58,7 +58,7 @@ private: * Execute check using n jobs for y files which are have * identical data, given within data. */ - void check(unsigned int jobs, int files, int result, const std::string &data, const CheckOptions &opt = {}) { + void check(unsigned int jobs, int files, int result, const std::string &data, const CheckOptions& opt = make_default_obj{}) { errout.str(""); output.str("");