Silence -Wdangling-reference warning in ApplyRule

This is a false-positive because the functions in question return
a reference to memory in a static variable that remains fixed after
program start.

This commit adds a macro for the `[[gnu::no_dangling]]` attribute to
ignore the warning for the tagged functions and uses that macro on
both functions returning references to the static variable.
This commit is contained in:
Johannes Schmidt 2026-02-12 15:00:29 +01:00
parent 30fc4e2160
commit afe17f10c1

View file

@ -81,8 +81,8 @@ public:
const Expression::Ptr& filter, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm,
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
static const std::vector<ApplyRule::Ptr>& GetRules(const Type::Ptr& sourceType, const Type::Ptr& targetType);
static const std::set<ApplyRule::Ptr>& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host);
static const std::set<ApplyRule::Ptr>& GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service);
[[gnu::no_dangling]] static const std::set<ApplyRule::Ptr>& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host);
[[gnu::no_dangling]] static const std::set<ApplyRule::Ptr>& GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service);
static bool GetTargetHosts(Expression* assignFilter, std::vector<const String *>& hosts, const Dictionary::Ptr& constants = nullptr);
static bool GetTargetServices(Expression* assignFilter, std::vector<std::pair<const String *, const String *>>& services, const Dictionary::Ptr& constants = nullptr);