Emit deprecation warning for use of &deprecated function parameters

Particularly, this is meant for using &deprecated on canonical
event/hook prototype parameters to encourage users to create handlers
to another, non-deprecated prototype.  i.e. for canonical prototypes,
we may not always want to put &deprecated directly on the prototype
itself since that signals deprecation of the ID entirely.
This commit is contained in:
Jon Siwek 2020-07-09 20:27:59 -07:00
parent 39f549ed68
commit 26b3d406b4
3 changed files with 42 additions and 1 deletions

View file

@ -450,7 +450,15 @@ static std::optional<zeek::FuncType::Prototype> func_type_check(const zeek::Func
return {};
}
return decl->FindPrototype(*impl->Params());
auto rval = decl->FindPrototype(*impl->Params());
if ( rval )
for ( auto i = 0; i < rval->args->NumFields(); ++i )
if ( rval->args->FieldDecl(i)->GetAttr(zeek::detail::ATTR_DEPRECATED) )
impl->Warn(fmt("use of deprecated parameter '%s'",
rval->args->FieldName(i)), decl, true);
return rval;
}
static bool canonical_arg_types_match(const zeek::FuncType* decl, const zeek::FuncType* impl)