mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/bit-1288'
* origin/topic/jsiwek/bit-1288: BIT-1288: Improve coercion of &default expressions. BIT-1288 #merged
This commit is contained in:
commit
bf35ed699c
7 changed files with 56 additions and 2 deletions
11
src/Attr.cc
11
src/Attr.cc
|
@ -265,6 +265,14 @@ void Attributes::CheckAttr(Attr* a)
|
|||
// Ok.
|
||||
break;
|
||||
|
||||
Expr* e = a->AttrExpr();
|
||||
if ( check_and_promote_expr(e, type) )
|
||||
{
|
||||
a->SetAttrExpr(e);
|
||||
// Ok.
|
||||
break;
|
||||
}
|
||||
|
||||
a->AttrExpr()->Error("&default value has inconsistent type", type);
|
||||
}
|
||||
|
||||
|
@ -297,8 +305,11 @@ void Attributes::CheckAttr(Attr* a)
|
|||
|
||||
Expr* e = a->AttrExpr();
|
||||
if ( check_and_promote_expr(e, ytype) )
|
||||
{
|
||||
a->SetAttrExpr(e);
|
||||
// Ok.
|
||||
break;
|
||||
}
|
||||
|
||||
Error("&default value has inconsistent type 2");
|
||||
}
|
||||
|
|
|
@ -45,6 +45,13 @@ public:
|
|||
attr_tag Tag() const { return tag; }
|
||||
Expr* AttrExpr() const { return expr; }
|
||||
|
||||
// Up to the caller to decide if previous expr can be unref'd since it may
|
||||
// not always be safe; e.g. expressions (at time of writing) don't always
|
||||
// keep careful track of referencing their operands, so doing something
|
||||
// like SetAttrExpr(coerce(AttrExpr())) must not completely unref the
|
||||
// previous expr as the new expr depends on it.
|
||||
void SetAttrExpr(Expr* e) { expr = e; }
|
||||
|
||||
int RedundantAttrOkay() const
|
||||
{ return tag == ATTR_REDEF || tag == ATTR_OPTIONAL; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue