mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Add a new attribute: &deprecated.
While scripts are parsed, a warning is raised for each usage of an identifier marked as &deprecated. This also works for BIFs. Addresses BIT-924, BIT-757.
This commit is contained in:
parent
f51dc5cbb8
commit
87962a48dd
12 changed files with 192 additions and 31 deletions
37
src/parse.y
37
src/parse.y
|
@ -2,7 +2,7 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
%}
|
||||
|
||||
%expect 75
|
||||
%expect 78
|
||||
|
||||
%token TOK_ADD TOK_ADD_TO TOK_ADDR TOK_ANY
|
||||
%token TOK_ATENDIF TOK_ATELSE TOK_ATIF TOK_ATIFDEF TOK_ATIFNDEF
|
||||
|
@ -24,7 +24,7 @@
|
|||
%token TOK_ATTR_PERSISTENT TOK_ATTR_SYNCHRONIZED
|
||||
%token TOK_ATTR_RAW_OUTPUT TOK_ATTR_MERGEABLE
|
||||
%token TOK_ATTR_PRIORITY TOK_ATTR_LOG TOK_ATTR_ERROR_HANDLER
|
||||
%token TOK_ATTR_TYPE_COLUMN
|
||||
%token TOK_ATTR_TYPE_COLUMN TOK_ATTR_DEPRECATED
|
||||
|
||||
%token TOK_DEBUG
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
|||
%right '!'
|
||||
%left '$' '[' ']' '(' ')' TOK_HAS_FIELD TOK_HAS_ATTR
|
||||
|
||||
%type <b> opt_no_test opt_no_test_block
|
||||
%type <b> opt_no_test opt_no_test_block opt_deprecated
|
||||
%type <str> TOK_ID TOK_PATTERN_TEXT single_pattern
|
||||
%type <id> local_id global_id def_global_id event_id global_or_event_id resolve_id begin_func
|
||||
%type <id_l> local_id_list
|
||||
|
@ -671,6 +671,9 @@ expr:
|
|||
}
|
||||
else
|
||||
$$ = new NameExpr(id);
|
||||
|
||||
if ( id->IsDeprecated() )
|
||||
reporter->Warning("deprecated (%s)", id->Name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -759,7 +762,7 @@ enum_body_elem:
|
|||
error messages if someboy tries to use constant variables as
|
||||
enumerator.
|
||||
*/
|
||||
TOK_ID '=' TOK_CONSTANT
|
||||
TOK_ID '=' TOK_CONSTANT opt_deprecated
|
||||
{
|
||||
set_location(@1, @3);
|
||||
assert(cur_enum_type);
|
||||
|
@ -768,7 +771,7 @@ enum_body_elem:
|
|||
reporter->Error("enumerator is not a count constant");
|
||||
else
|
||||
cur_enum_type->AddName(current_module, $1,
|
||||
$3->InternalUnsigned(), is_export);
|
||||
$3->InternalUnsigned(), is_export, $4);
|
||||
}
|
||||
|
||||
| TOK_ID '=' '-' TOK_CONSTANT
|
||||
|
@ -780,11 +783,11 @@ enum_body_elem:
|
|||
reporter->Error("enumerator is not a count constant");
|
||||
}
|
||||
|
||||
| TOK_ID
|
||||
| TOK_ID opt_deprecated
|
||||
{
|
||||
set_location(@1);
|
||||
assert(cur_enum_type);
|
||||
cur_enum_type->AddName(current_module, $1, is_export);
|
||||
cur_enum_type->AddName(current_module, $1, is_export, $2);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -963,7 +966,12 @@ type:
|
|||
$$ = error_type();
|
||||
}
|
||||
else
|
||||
{
|
||||
Ref($$);
|
||||
|
||||
if ( $1->IsDeprecated() )
|
||||
reporter->Warning("deprecated (%s)", $1->Name());
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1265,6 +1273,8 @@ attr:
|
|||
{ $$ = new Attr(ATTR_LOG); }
|
||||
| TOK_ATTR_ERROR_HANDLER
|
||||
{ $$ = new Attr(ATTR_ERROR_HANDLER); }
|
||||
| TOK_ATTR_DEPRECATED
|
||||
{ $$ = new Attr(ATTR_DEPRECATED); }
|
||||
;
|
||||
|
||||
stmt:
|
||||
|
@ -1450,6 +1460,10 @@ event:
|
|||
{
|
||||
set_location(@1, @4);
|
||||
$$ = new EventExpr($1, $3);
|
||||
ID* id = lookup_ID($1, current_module.c_str());
|
||||
|
||||
if ( id && id->IsDeprecated() )
|
||||
reporter->Warning("deprecated (%s)", id->Name());
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1556,6 +1570,9 @@ global_or_event_id:
|
|||
if ( ! $$->IsGlobal() )
|
||||
$$->Error("already a local identifier");
|
||||
|
||||
if ( $$->IsDeprecated() )
|
||||
reporter->Warning("deprecated (%s)", $$->Name());
|
||||
|
||||
delete [] $1;
|
||||
}
|
||||
|
||||
|
@ -1597,6 +1614,12 @@ opt_no_test_block:
|
|||
|
|
||||
{ $$ = false; }
|
||||
|
||||
opt_deprecated:
|
||||
TOK_ATTR_DEPRECATED
|
||||
{ $$ = true; }
|
||||
|
|
||||
{ $$ = false; }
|
||||
|
||||
%%
|
||||
|
||||
int yyerror(const char msg[])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue