mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 03:28:19 +00:00
parent
e22bf8ebb6
commit
8ede22f6ec
11 changed files with 76 additions and 10 deletions
13
src/Var.cc
13
src/Var.cc
|
@ -26,8 +26,7 @@
|
||||||
namespace zeek::detail
|
namespace zeek::detail
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool add_prototype(const IDPtr& id, Type* t, std::vector<AttrPtr>* attrs,
|
static bool add_prototype(const IDPtr& id, Type* t, std::vector<AttrPtr>* attrs)
|
||||||
const ExprPtr& init)
|
|
||||||
{
|
{
|
||||||
if ( ! IsFunc(id->GetType()->Tag()) )
|
if ( ! IsFunc(id->GetType()->Tag()) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -53,12 +52,6 @@ static bool add_prototype(const IDPtr& id, Type* t, std::vector<AttrPtr>* attrs,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( init )
|
|
||||||
{
|
|
||||||
init->Error("initialization not allowed during event/hook alternate prototype declaration");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& canon_args = canon_ft->Params();
|
const auto& canon_args = canon_ft->Params();
|
||||||
const auto& alt_args = alt_ft->Params();
|
const auto& alt_args = alt_ft->Params();
|
||||||
|
|
||||||
|
@ -221,8 +214,8 @@ static void make_var(const IDPtr& id, TypePtr t, InitClass c, ExprPtr init,
|
||||||
|
|
||||||
else if ( dt != VAR_REDEF || init || ! attr )
|
else if ( dt != VAR_REDEF || init || ! attr )
|
||||||
{
|
{
|
||||||
if ( IsFunc(id->GetType()->Tag()) )
|
if ( IsFunc(id->GetType()->Tag()) && ! init )
|
||||||
add_prototype(id, t.get(), attr.get(), init);
|
add_prototype(id, t.get(), attr.get());
|
||||||
else
|
else
|
||||||
id->Error("already defined", init.get());
|
id->Error("already defined", init.get());
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 2 and <...>/redeclaration-redefinition-errors.zeek, line 3: already defined (f)
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 3 and <...>/redeclaration-redefinition-errors.zeek, line 2: redeclaration of function (function() : void and function() : void)
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 4 and <...>/redeclaration-redefinition-errors.zeek, line 5: already defined (f)
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 4 and <...>/redeclaration-redefinition-errors.zeek, line 3: redeclaration of function (function() : void and function() : void)
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 3 and <...>/redeclaration-redefinition-errors.zeek, line 4: already defined (x)
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 2 and <...>/redeclaration-redefinition-errors.zeek, line 1: alternate function prototype already exists (event() and record { })
|
|
@ -0,0 +1,3 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 2 and <...>/redeclaration-redefinition-errors.zeek, line 1: incompatible function flavor (hook() : bool and event())
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 3 and <...>/redeclaration-redefinition-errors.zeek, line 1: incompatible function flavor (function() : void and event())
|
|
@ -0,0 +1,3 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 2 and <...>/redeclaration-redefinition-errors.zeek, line 1: incompatible function flavor (hook() : bool and function() : void)
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 3 and <...>/redeclaration-redefinition-errors.zeek, line 1: incompatible function flavor (event() and function() : void)
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redeclaration-redefinition-errors.zeek, line 6 and <...>/redeclaration-redefinition-errors.zeek, line 7: already defined (x)
|
|
@ -0,0 +1,53 @@
|
||||||
|
# @TEST-DOC: Test some redeclaration, redefinition errors.
|
||||||
|
|
||||||
|
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
global x = 1;
|
||||||
|
global x = 2;
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
global f: function() = function() { };
|
||||||
|
global f: function() = function() { };
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
global f: function();
|
||||||
|
global f: function();
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local f = function() { };
|
||||||
|
local f = function() { };
|
||||||
|
}
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local f: function();
|
||||||
|
local f: function();
|
||||||
|
}
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local x = 1;
|
||||||
|
local x = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
global ev: event();
|
||||||
|
global ev: event();
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
global f: event();
|
||||||
|
global f: hook();
|
||||||
|
global f: function();
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
global f = function() { };
|
||||||
|
global f: hook();
|
||||||
|
global f: event();
|
Loading…
Add table
Add a link
Reference in a new issue