From f526d235d1bf4bbe02bcd7840493857acac7da1a Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 14 Oct 2000 02:23:02 +0000 Subject: [PATCH] Check for missing concat subexpressions (PR#11) --- elab_net.cc | 12 +++++++++++- parse.y | 8 ++++---- pform_dump.cc | 18 ++++++++++++------ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/elab_net.cc b/elab_net.cc index 3e30fcd7f..5c6a71f14 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 */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: elab_net.cc,v 1.50 2000/10/08 04:59:36 steve Exp $" +#ident "$Id: elab_net.cc,v 1.51 2000/10/14 02:23:02 steve Exp $" #endif # include "PExpr.h" @@ -925,6 +925,13 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path, /* Elaborate the operands of the concatenation. */ for (unsigned idx = 0 ; idx < nets.count() ; idx += 1) { + if (parms_[idx] == 0) { + cerr << get_line() << ": error: Empty expressions " + << "not allowed in concatenations." << endl; + errors += 1; + continue; + } + /* Look for the special case of an unsized number in a concatenation expression. Mark this as an error, but allow elaboration to continue to see if I can find @@ -1745,6 +1752,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path, /* * $Log: elab_net.cc,v $ + * Revision 1.51 2000/10/14 02:23:02 steve + * Check for missing concat subexpressions (PR#11) + * * Revision 1.50 2000/10/08 04:59:36 steve * Fix repeat concatenation with multiple expressions (PR#10) * diff --git a/parse.y b/parse.y index f510d966f..0e04ea2b1 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: parse.y,v 1.106 2000/09/23 03:04:10 steve Exp $" +#ident "$Id: parse.y,v 1.107 2000/10/14 02:23:02 steve Exp $" #endif # include "parse_misc.h" @@ -732,7 +732,7 @@ expression_list { svector*tmp = new svector(*$1, 0); delete $1; $$ = tmp; - } + } ; @@ -803,8 +803,8 @@ expr_primary { $$ = $2; } | '{' expression_list '}' { PEConcat*tmp = new PEConcat(*$2); - tmp->set_file(@2.text); - tmp->set_lineno(@2.first_line); + tmp->set_file(@1.text); + tmp->set_lineno(@1.first_line); delete $2; $$ = tmp; } diff --git a/pform_dump.cc b/pform_dump.cc index 9a9b9164d..738423f25 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: pform_dump.cc,v 1.61 2000/07/26 05:08:07 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.62 2000/10/14 02:23:02 steve Exp $" #endif /* @@ -83,9 +83,12 @@ void PEConcat::dump(ostream&out) const return; } - out << "{" << *parms_[0]; - for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) - out << ", " << *parms_[idx]; + out << "{"; + if (parms_[0]) out << *parms_[0]; + for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) { + out << ", "; + if (parms_[idx]) out << *parms_[idx]; + } out << "}"; @@ -97,10 +100,10 @@ void PECallFunction::dump(ostream &out) const out << name_ << "("; if (parms_.count() > 0) { - parms_[0]->dump(out); + if (parms_[0]) parms_[0]->dump(out); for (unsigned idx = 1; idx < parms_.count(); ++idx) { out << ", "; - parms_[idx]->dump(out); + if (parms_[idx]) parms_[idx]->dump(out); } } out << ")"; @@ -780,6 +783,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.62 2000/10/14 02:23:02 steve + * Check for missing concat subexpressions (PR#11) + * * Revision 1.61 2000/07/26 05:08:07 steve * Parse disable statements to pform. *