mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Allow passing a location to BroObj::Warning and BroObj::Error.
This allows callers (such as check_and_promote) to pass an expression location to be logged if the location doesn't exist in the value being promoted.
This commit is contained in:
parent
8ca2cff13f
commit
2d61ea5cd6
4 changed files with 16 additions and 14 deletions
10
src/Val.cc
10
src/Val.cc
|
@ -3556,7 +3556,7 @@ bool OpaqueVal::DoUnserialize(UnserialInfo* info)
|
|||
return true;
|
||||
}
|
||||
|
||||
Val* check_and_promote(Val* v, const BroType* t, int is_init)
|
||||
Val* check_and_promote(Val* v, const BroType* t, int is_init, const Location* expr_location)
|
||||
{
|
||||
if ( ! v )
|
||||
return 0;
|
||||
|
@ -3580,7 +3580,7 @@ Val* check_and_promote(Val* v, const BroType* t, int is_init)
|
|||
if ( same_type(t, vt, is_init) )
|
||||
return v;
|
||||
|
||||
t->Error("type clash", v);
|
||||
t->Error("type clash", v, 0, expr_location);
|
||||
Unref(v);
|
||||
return 0;
|
||||
}
|
||||
|
@ -3589,9 +3589,9 @@ Val* check_and_promote(Val* v, const BroType* t, int is_init)
|
|||
(! IsArithmetic(v_tag) || t_tag != TYPE_TIME || ! v->IsZero()) )
|
||||
{
|
||||
if ( t_tag == TYPE_LIST || v_tag == TYPE_LIST )
|
||||
t->Error("list mixed with scalar", v);
|
||||
t->Error("list mixed with scalar", v, 0, expr_location);
|
||||
else
|
||||
t->Error("arithmetic mixed with non-arithmetic", v);
|
||||
t->Error("arithmetic mixed with non-arithmetic", v, 0, expr_location);
|
||||
Unref(v);
|
||||
return 0;
|
||||
}
|
||||
|
@ -3604,7 +3604,7 @@ Val* check_and_promote(Val* v, const BroType* t, int is_init)
|
|||
TypeTag mt = max_type(t_tag, v_tag);
|
||||
if ( mt != t_tag )
|
||||
{
|
||||
t->Error("over-promotion of arithmetic value", v);
|
||||
t->Error("over-promotion of arithmetic value", v, 0, expr_location);
|
||||
Unref(v);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue