deprecate mixing scalars and vectors

This commit is contained in:
Vern Paxson 2018-06-22 10:03:13 -07:00
parent 6c8562bbdd
commit cff68b4371
2 changed files with 18 additions and 2 deletions

7
NEWS
View file

@ -356,6 +356,13 @@ Deprecated Functionality
removal with the next Bro release. Bro's new configuration framework
is taking its place.
- Mixing of scalars and vectors, such as "v + e" yielding a vector
corresponding to the vector v with the scalar e added to each of
its elements, has been deprecated.
- The undocumented feature of using "&&" and "||" operators for patterns
has been deprecated.
Bro 2.5.1
=========

View file

@ -909,11 +909,17 @@ void BinaryExpr::PromoteOps(TypeTag t)
TypeTag bt1 = op1->Type()->Tag();
TypeTag bt2 = op2->Type()->Tag();
if ( IsVector(bt1) )
bool is_vec1 = IsVector(bt1);
bool is_vec2 = IsVector(bt2);
if ( is_vec1 )
bt1 = op1->Type()->AsVectorType()->YieldType()->Tag();
if ( IsVector(bt2) )
if ( is_vec2 )
bt2 = op2->Type()->AsVectorType()->YieldType()->Tag();
if ( (is_vec1 || is_vec2) && ! (is_vec1 && is_vec2) )
reporter->Warning("mixing vector and scalar operands is deprecated");
if ( bt1 != t )
op1 = new ArithCoerceExpr(op1, t);
if ( bt2 != t )
@ -1003,7 +1009,10 @@ IncrExpr::IncrExpr(BroExprTag arg_tag, Expr* arg_op)
if ( ! IsIntegral(t->AsVectorType()->YieldType()->Tag()) )
ExprError("vector elements must be integral for increment operator");
else
{
reporter->Warning("increment/decrement operations for vectors deprecated");
SetType(t->Ref());
}
}
else
{