From 4902c222fb3ff282070e8d75716b994ab3a4a972 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 1 Sep 2005 04:10:47 +0000 Subject: [PATCH] Check operand types for compatibility. --- elab_expr.cc | 25 ++++++++++++++++++++++--- elab_net.cc | 14 +++++++++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 5c2dd0f45..65283f510 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_expr.cc,v 1.94 2005/07/11 16:56:50 steve Exp $" +#ident "$Id: elab_expr.cc,v 1.95 2005/09/01 04:10:47 steve Exp $" #endif # include "config.h" @@ -134,10 +134,17 @@ NetEBinary* PEBinary::elaborate_expr_base_(Design*des, tmp->set_line(*this); break; - case 'e': /* == */ case 'E': /* === */ - case 'n': /* != */ case 'N': /* !== */ + if (lp->expr_type() == IVL_VT_REAL + || rp->expr_type() == IVL_VT_REAL) { + cerr << get_line() << ": error: Case equality may not " + << "have real operands." << endl; + return 0; + } + /* Fall through... */ + case 'e': /* == */ + case 'n': /* != */ if (dynamic_cast(rp) && (lp->expr_width() > rp->expr_width())) rp->set_width(lp->expr_width()); @@ -908,6 +915,15 @@ NetETernary*PETernary::elaborate_expr(Design*des, NetScope*scope, bool) const return 0; } + if (tru->expr_type() != fal->expr_type()) { + cerr << get_line() << ": error: Data types " + << tru->expr_type() << " and " + << fal->expr_type() << " of ternary" + << " do not match." << endl; + des->errors += 1; + return 0; + } + NetETernary*res = new NetETernary(con, tru, fal); res->set_line(*this); return res; @@ -1019,6 +1035,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const /* * $Log: elab_expr.cc,v $ + * Revision 1.95 2005/09/01 04:10:47 steve + * Check operand types for compatibility. + * * Revision 1.94 2005/07/11 16:56:50 steve * Remove NetVariable and ivl_variable_t structures. * diff --git a/elab_net.cc b/elab_net.cc index 34003eb78..f0c8fef31 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_net.cc,v 1.171 2005/08/31 05:07:31 steve Exp $" +#ident "$Id: elab_net.cc,v 1.172 2005/09/01 04:10:47 steve Exp $" #endif # include "config.h" @@ -292,6 +292,14 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, NetScope*scope, if (rsig->vector_width() < lsig->vector_width()) rsig = pad_to_width(des, rsig, lsig->vector_width()); + if (lsig->data_type() != rsig->data_type()) { + cerr << get_line() << ": error: Data types of left and " + << "right operands of " << op_ << " do not match" + << endl; + des->errors += 1; + return 0; + } + if (lsig->vector_width() != rsig->vector_width()) { cerr << get_line() << ": internal error: lsig width (" << lsig->vector_width() << ") != rsig pin width (" @@ -305,6 +313,7 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, NetScope*scope, NetNet*osig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, lsig->vector_width()); osig->local_flag(true); + osig->data_type( lsig->data_type() ); NetLogic::TYPE gtype=NetLogic::AND; switch (op_) { @@ -2628,6 +2637,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope, /* * $Log: elab_net.cc,v $ + * Revision 1.172 2005/09/01 04:10:47 steve + * Check operand types for compatibility. + * * Revision 1.171 2005/08/31 05:07:31 steve * Handle memory references is continuous assignments. *