Operand of increment/decrement should not be a number

The patch adds necessary error checking to verify that the operands of
increment decrement operator is not number.

Signed-off-by: Prasad Joshi <prasad@canopusconsultancy.com>
This commit is contained in:
Prasad Joshi 2011-08-19 14:02:35 +05:30 committed by Stephen Williams
parent 51b1d57f19
commit 5311aeaa19
1 changed files with 10 additions and 0 deletions

View File

@ -3646,6 +3646,16 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
des->errors += 1;
return 0;
} else if (t == IVL_VT_LOGIC || t == IVL_VT_BOOL) {
if (dynamic_cast<NetEConst *> (ip)) {
/* invalid operand: operand is a constant number */
cerr << get_fileline() << ": error: "
<< "inappropriate use of "
<< human_readable_op(op_, true)
<< " operator." << endl;
des->errors += 1;
return 0;
}
tmp = new NetEUnary(op_, ip, expr_wid, signed_flag_);
tmp->set_line(*this);
} else {