From 5311aeaa1983fbc8d9ffe538ffda96e7043eefc0 Mon Sep 17 00:00:00 2001 From: Prasad Joshi Date: Fri, 19 Aug 2011 14:02:35 +0530 Subject: [PATCH] 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 --- elab_expr.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/elab_expr.cc b/elab_expr.cc index 4c92faf91..009edd6fa 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -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 (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 {