mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Improve use of &deprecated on functions.
- Don't report warnings on function definition if declaration is marked deprecated. - Allow &deprecated to apply to a standalone function definition.
This commit is contained in:
parent
87962a48dd
commit
011e2cdd32
7 changed files with 53 additions and 6 deletions
23
src/parse.y
23
src/parse.y
|
@ -227,6 +227,18 @@ static bool expr_is_table_type_name(const Expr* expr)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool has_attr(const attr_list* al, attr_tag tag)
|
||||
{
|
||||
if ( ! al )
|
||||
return false;
|
||||
|
||||
for ( int i = 0; i < al->length(); ++i )
|
||||
if ( (*al)[i]->Tag() == tag )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
|
||||
%union {
|
||||
|
@ -1147,6 +1159,9 @@ func_body:
|
|||
{
|
||||
saved_in_init.push_back(in_init);
|
||||
in_init = 0;
|
||||
|
||||
if ( has_attr($1, ATTR_DEPRECATED) )
|
||||
current_scope()->ScopeID()->MakeDeprecated();
|
||||
}
|
||||
|
||||
stmt_list
|
||||
|
@ -1571,7 +1586,13 @@ global_or_event_id:
|
|||
$$->Error("already a local identifier");
|
||||
|
||||
if ( $$->IsDeprecated() )
|
||||
reporter->Warning("deprecated (%s)", $$->Name());
|
||||
{
|
||||
BroType* t = $$->Type();
|
||||
|
||||
if ( t->Tag() != TYPE_FUNC ||
|
||||
t->AsFuncType()->Flavor() != FUNC_FLAVOR_FUNCTION )
|
||||
reporter->Warning("deprecated (%s)", $$->Name());
|
||||
}
|
||||
|
||||
delete [] $1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue