testrunner: fix clang compile error related to `dinit` (#5297)

This fixes the compile error introduced in 5d201c4.
This commit is contained in:
Paul Fultz II 2023-08-08 16:55:07 -05:00 committed by GitHub
parent f1749ab7ad
commit 037bed5b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 16 deletions

View File

@ -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<class T>
operator T() const // NOLINT
{
return T{};
}
};
#endif // helpersH

View File

@ -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<std::string> 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("");

View File

@ -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<std::string> filesList;
@ -72,7 +72,7 @@ private:
std::vector<std::string> 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();

View File

@ -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<std::string> 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("");