mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 05:28:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/alternate-hook-event-prototypes'
* origin/topic/jsiwek/alternate-hook-event-prototypes: Add warning for ineffective &default arguments in handlers Fix frame size allocation of alternate event/hook handlers Emit error for alternate event/hook prototype args with attributes Improve alternate event/hook prototype matching Allow alternate event/hook prototype declarations
This commit is contained in:
commit
ba1c03188f
24 changed files with 715 additions and 16 deletions
|
@ -0,0 +1,2 @@
|
|||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes-invalid-arg/alternate-event-hook-prototypes-invalid-arg.zeek, line 5 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes-invalid-arg/alternate-event-hook-prototypes-invalid-arg.zeek, line 4: alternate function prototype arg 'nope' not found in canonical prototype (event(nope:string; cantdothis:count;) and event(s:string; c:count;))
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes-invalid-arg/alternate-event-hook-prototypes-invalid-arg.zeek, line 8 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes-invalid-arg/alternate-event-hook-prototypes-invalid-arg.zeek, line 7: alternate function prototype arg 'andnotthiseither' not found in canonical prototype (hook(andnotthiseither:addr;) : bool and hook(s:string; c:count;) : bool)
|
|
@ -0,0 +1,12 @@
|
|||
warning in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes/alternate-event-hook-prototypes.zeek, line 68 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.alternate-event-hook-prototypes/alternate-event-hook-prototypes.zeek, line 10: use of deprecated prototype (hook(c:count;) : bool and my_hook)
|
||||
my_hook, infinite, 13
|
||||
my_hook, 13, infinite
|
||||
my_hook, infinite
|
||||
my_hook, 13
|
||||
my_hook
|
||||
my_event, enantiodromia, 42
|
||||
my_event, 42, enantiodromia
|
||||
my_event, enantiodromia
|
||||
my_event, 42
|
||||
my_event
|
||||
foo, C
|
|
@ -0,0 +1,6 @@
|
|||
foo, A, B, C
|
||||
foo, A, B, C
|
||||
reverse foo, A, B, C
|
||||
foo a, A
|
||||
foo b, B
|
||||
foo c, C
|
|
@ -0,0 +1 @@
|
|||
error in ./bad.zeek, line 2 and ./bad.zeek, line 1: alternate function prototype arguments may not have attributes: arg 'a' (event(c:string; b:string; a:string;) and event(a:string; b:string; c:string;))
|
|
@ -0,0 +1,6 @@
|
|||
foo, A, B, C
|
||||
foo, A, B, C
|
||||
reverse foo, A, B, C
|
||||
foo a, A
|
||||
foo b, B
|
||||
foo c, C
|
|
@ -0,0 +1,8 @@
|
|||
warning in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.ineffective-default-args/ineffective-default-args.zeek, line 9: &default on parameter 'b' has no effect (not a event declaration)
|
||||
warning in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.ineffective-default-args/ineffective-default-args.zeek, line 19: &default on parameter 'c' has no effect (not a event declaration)
|
||||
bar, A, B
|
||||
baz, A, B
|
||||
qux, Q, Q
|
||||
grault, A, B
|
||||
corge, C
|
||||
foo c, C
|
|
@ -0,0 +1,8 @@
|
|||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 13 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 4: use of undeclared alternate prototype (event(c:count; s:string;) and my_event)
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 18 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 4: use of undeclared alternate prototype (event(s:string;) and my_event)
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 23 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 4: use of undeclared alternate prototype (event(c:count;) and my_event)
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 28 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 4: use of undeclared alternate prototype (event() and my_event)
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 38 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 6: use of undeclared alternate prototype (hook(c:count; s:string;) : bool and my_hook)
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 43 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 6: use of undeclared alternate prototype (hook(s:string;) : bool and my_hook)
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 48 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 6: use of undeclared alternate prototype (hook(c:count;) : bool and my_hook)
|
||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 53 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.undeclared-alternate-event-hook-prototype/undeclared-alternate-event-hook-prototype.zeek, line 6: use of undeclared alternate prototype (hook() : bool and my_hook)
|
|
@ -0,0 +1,24 @@
|
|||
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
global my_event: event(s: string, c: count);
|
||||
global my_event: event(nope: string, cantdothis: count);
|
||||
|
||||
global my_hook: hook(s: string, c: count);
|
||||
global my_hook: hook(andnotthiseither: addr);
|
||||
|
||||
event my_event(s: string, c: count)
|
||||
{
|
||||
print "my_event", s, c;
|
||||
}
|
||||
|
||||
hook my_hook(s: string, c: count)
|
||||
{
|
||||
print "my_hook", s, c;
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
hook my_hook("infinite", 13);
|
||||
event my_event("enantiodromia", 42);
|
||||
}
|
83
testing/btest/language/alternate-event-hook-prototypes.zeek
Normal file
83
testing/btest/language/alternate-event-hook-prototypes.zeek
Normal file
|
@ -0,0 +1,83 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
global my_event: event(s: string, c: count);
|
||||
global my_event: event(c: count, s: string);
|
||||
global my_event: event(s: string);
|
||||
global my_event: event(c: count);
|
||||
global my_event: event();
|
||||
|
||||
global my_hook: hook(s: string, c: count);
|
||||
global my_hook: hook(c: count, s: string);
|
||||
global my_hook: hook(s: string);
|
||||
global my_hook: hook(c: count) &deprecated;
|
||||
global my_hook: hook();
|
||||
|
||||
# Required Frame size gets (re)calculated on AddBody, so this "foo" setup is
|
||||
# checking that if the only existing body doesn't use all arguments, the Frame
|
||||
# size is still allocated sufficiently to hold all arguments of the canonical
|
||||
# prototype.
|
||||
global foo: event(a: string, b: string, c: string);
|
||||
global foo: event(c: string);
|
||||
|
||||
event foo(c: string)
|
||||
{
|
||||
print "foo", c;
|
||||
}
|
||||
|
||||
event my_event(s: string, c: count)
|
||||
{
|
||||
print "my_event", s, c;
|
||||
}
|
||||
|
||||
event my_event(c: count, s: string)
|
||||
{
|
||||
print "my_event", c, s;
|
||||
}
|
||||
|
||||
event my_event(s: string)
|
||||
{
|
||||
print "my_event", s;
|
||||
}
|
||||
|
||||
event my_event(c: count)
|
||||
{
|
||||
print "my_event", c;
|
||||
}
|
||||
|
||||
event my_event()
|
||||
{
|
||||
print "my_event";
|
||||
}
|
||||
|
||||
hook my_hook(s: string, c: count)
|
||||
{
|
||||
print "my_hook", s, c;
|
||||
}
|
||||
|
||||
hook my_hook(c: count, s: string)
|
||||
{
|
||||
print "my_hook", c, s;
|
||||
}
|
||||
|
||||
hook my_hook(s: string)
|
||||
{
|
||||
print "my_hook", s;
|
||||
}
|
||||
|
||||
hook my_hook(c: count)
|
||||
{
|
||||
print "my_hook", c;
|
||||
}
|
||||
|
||||
hook my_hook()
|
||||
{
|
||||
print "my_hook";
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
hook my_hook("infinite", 13);
|
||||
event my_event("enantiodromia", 42);
|
||||
event foo("A", "B", "C");
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT > out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
global foo: event(a: string, b: string, c: string);
|
||||
global foo: event(c: string, b: string, a: string);
|
||||
global foo: event(a: string);
|
||||
global foo: event(b: string);
|
||||
global foo: event(c: string);
|
||||
|
||||
event foo(a: string, b: string, c: string)
|
||||
{
|
||||
print "foo", a, b, c;
|
||||
}
|
||||
|
||||
event foo(mya: string, b: string, c: string)
|
||||
{
|
||||
print "foo", mya, b, c;
|
||||
}
|
||||
|
||||
event foo(c: string, b: string, a: string)
|
||||
{
|
||||
print "reverse foo", a, b, c;
|
||||
}
|
||||
|
||||
event foo(a: string)
|
||||
{
|
||||
print "foo a", a;
|
||||
}
|
||||
|
||||
event foo(b: string)
|
||||
{
|
||||
print "foo b", b;
|
||||
}
|
||||
|
||||
event foo(c: string)
|
||||
{
|
||||
print "foo c", c;
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
event foo("A", "B", "C");
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC-FAIL: zeek -b bad.zeek >errors 2>&1
|
||||
# @TEST-EXEC: btest-diff out
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff errors
|
||||
|
||||
global foo: event(a: string, b: string, c: string &default="C");
|
||||
global foo: event(c: string, b: string, a: string);
|
||||
global foo: event(a: string);
|
||||
global foo: event(b: string);
|
||||
global foo: event(c: string);
|
||||
|
||||
event foo(a: string, b: string, c: string)
|
||||
{
|
||||
print "foo", a, b, c;
|
||||
}
|
||||
|
||||
event foo(mya: string, b: string, c: string)
|
||||
{
|
||||
print "foo", mya, b, c;
|
||||
}
|
||||
|
||||
event foo(c: string, b: string, a: string)
|
||||
{
|
||||
print "reverse foo", a, b, c;
|
||||
}
|
||||
|
||||
event foo(a: string)
|
||||
{
|
||||
print "foo a", a;
|
||||
}
|
||||
|
||||
event foo(b: string)
|
||||
{
|
||||
print "foo b", b;
|
||||
}
|
||||
|
||||
event foo(c: string)
|
||||
{
|
||||
print "foo c", c;
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
event foo("A", "B");
|
||||
}
|
||||
|
||||
@TEST-START-FILE bad.zeek
|
||||
global foo: event(a: string, b: string, c: string &default="C");
|
||||
global foo: event(c: string, b: string, a: string &default="A");
|
||||
@TEST-END-FILE bad.zeek
|
54
testing/btest/language/ineffective-default-args.zeek
Normal file
54
testing/btest/language/ineffective-default-args.zeek
Normal file
|
@ -0,0 +1,54 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
global grault: event(a: string, b: string &default="B");
|
||||
|
||||
global foo: event(a: string, b: string, c: string &default="C");
|
||||
global foo: event(c: string);
|
||||
|
||||
event grault(a: string, b: string &default="G")
|
||||
{
|
||||
print "grault", a, b;
|
||||
}
|
||||
|
||||
event corge(c: string &default="C")
|
||||
{
|
||||
print "corge", c;
|
||||
}
|
||||
|
||||
event foo(c: string &default="CCCC")
|
||||
{
|
||||
print "foo c", c;
|
||||
}
|
||||
|
||||
global bar: function(a: string, b: string);
|
||||
|
||||
function bar(a: string &default="A", b: string &default="B")
|
||||
{
|
||||
print "bar", a, b;
|
||||
}
|
||||
|
||||
global baz: function(a: string &default="A", b: string &default="B");
|
||||
|
||||
function baz(a: string, b: string)
|
||||
{
|
||||
print "baz", a, b;
|
||||
}
|
||||
|
||||
global qux: function(a: string &default="A", b: string &default="B");
|
||||
|
||||
function qux(a: string &default="Q", b: string &default="Q")
|
||||
{
|
||||
print "qux", a, b;
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
bar();
|
||||
baz();
|
||||
qux();
|
||||
event grault("A");
|
||||
event corge();
|
||||
event foo("A", "B");
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
global my_event: event(s: string, c: count);
|
||||
|
||||
global my_hook: hook(s: string, c: count);
|
||||
|
||||
event my_event(s: string, c: count)
|
||||
{
|
||||
print "my_event", s, c;
|
||||
}
|
||||
|
||||
event my_event(c: count, s: string)
|
||||
{
|
||||
print "my_event", c, s;
|
||||
}
|
||||
|
||||
event my_event(s: string)
|
||||
{
|
||||
print "my_event", s;
|
||||
}
|
||||
|
||||
event my_event(c: count)
|
||||
{
|
||||
print "my_event", c;
|
||||
}
|
||||
|
||||
event my_event()
|
||||
{
|
||||
print "my_event";
|
||||
}
|
||||
|
||||
hook my_hook(s: string, c: count)
|
||||
{
|
||||
print "my_hook", s, c;
|
||||
}
|
||||
|
||||
hook my_hook(c: count, s: string)
|
||||
{
|
||||
print "my_hook", c, s;
|
||||
}
|
||||
|
||||
hook my_hook(s: string)
|
||||
{
|
||||
print "my_hook", s;
|
||||
}
|
||||
|
||||
hook my_hook(c: count)
|
||||
{
|
||||
print "my_hook", c;
|
||||
}
|
||||
|
||||
hook my_hook()
|
||||
{
|
||||
print "my_hook";
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
hook my_hook("infinite", 13);
|
||||
event my_event("enantiodromia", 42);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue