mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
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:
parent
39f549ed68
commit
26b3d406b4
3 changed files with 42 additions and 1 deletions
10
src/Var.cc
10
src/Var.cc
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue