Source: Suppress gcc 15 -Wmaybe-uninitialized in std::function

The warning is in the `std::function` implementation.
This commit is contained in:
Brad King
2025-04-22 15:48:21 -04:00
parent b1c22bdc38
commit 16455374cf
2 changed files with 18 additions and 0 deletions

View File

@@ -47,10 +47,19 @@ auto const RootVersionHelper = JSONHelperBuilder::Object<TopVersion>().Bind(
bool ResourceIdHelper(std::string& out, Json::Value const* value,
cmJSONState* state)
{
#if defined(__GNUC__) && __GNUC__ >= 15
# define CM_GCC_diagnostic_push_Wmaybe_uninitialized
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
if (!JSONHelperBuilder::String(cmCTestResourceSpecErrors::INVALID_RESOURCE)(
out, value, state)) {
return false;
}
#ifdef CM_GCC_diagnostic_push_Wmaybe_uninitialized
# pragma GCC diagnostic pop
# undef CM_GCC_diagnostic_push_Wmaybe_uninitialized
#endif
cmsys::RegularExpressionMatch match;
if (!IdRegex.find(out.c_str(), match)) {
cmCTestResourceSpecErrors::INVALID_RESOURCE(value, state);

View File

@@ -52,6 +52,11 @@ ObjectErrorGenerator INVALID_NAMED_OBJECT(
std::function<std::string(Json::Value const*, cmJSONState*)> const&
nameGenerator)
{
#if defined(__GNUC__) && __GNUC__ >= 15
# define CM_GCC_diagnostic_push_Wmaybe_uninitialized
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
return [nameGenerator](
ObjectError errorType,
Json::Value::Members const& extraFields) -> ErrorGenerator {
@@ -85,6 +90,10 @@ ObjectErrorGenerator INVALID_NAMED_OBJECT(
}
};
};
#ifdef CM_GCC_diagnostic_push_Wmaybe_uninitialized
# pragma GCC diagnostic pop
# undef CM_GCC_diagnostic_push_Wmaybe_uninitialized
#endif
}
ErrorGenerator INVALID_OBJECT(ObjectError errorType,