diff --git a/elab_sig.cc b/elab_sig.cc index e7169fed0..2e046ac69 100644 --- a/elab_sig.cc +++ b/elab_sig.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_sig.cc,v 1.18 2001/12/03 04:47:14 steve Exp $" +#ident "$Id: elab_sig.cc,v 1.19 2002/01/23 03:35:17 steve Exp $" #endif # include "config.h" @@ -237,6 +237,17 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const string fname = scope->basename(); assert(scope->type() == NetScope::FUNC); + /* Make sure the function has at least one input port. If it + fails this test, print an error message. Keep going so we + can find more errors. */ + if (ports_ == 0) { + cerr << get_line() << ": error: Function " << fname + << " has no ports." << endl; + cerr << get_line() << ": : Functions must have" + << " at least one input port." << endl; + des->errors += 1; + } + svectorports (ports_? ports_->count()+1 : 1); /* Get the reg for the return value. I know the name of the @@ -484,6 +495,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const /* * $Log: elab_sig.cc,v $ + * Revision 1.19 2002/01/23 03:35:17 steve + * Detect incorrect function ports. + * * Revision 1.18 2001/12/03 04:47:14 steve * Parser and pform use hierarchical names as hname_t * objects instead of encoded strings. diff --git a/parse.y b/parse.y index 4488516e4..899f3c97d 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.144 2002/01/12 04:03:39 steve Exp $" +#ident "$Id: parse.y,v 1.145 2002/01/23 03:35:17 steve Exp $" #endif # include "config.h" @@ -900,6 +900,20 @@ function_item @1.text, @1.first_line); $$ = tmp; } + | K_output range_opt list_of_variables ';' + { svector*tmp + = pform_make_task_ports(NetNet::PINPUT, $2, $3, + @1.text, @1.first_line); + $$ = tmp; + yyerror(@1, "Functions may not have output ports."); + } + | K_inout range_opt list_of_variables ';' + { svector*tmp + = pform_make_task_ports(NetNet::PINPUT, $2, $3, + @1.text, @1.first_line); + $$ = tmp; + yyerror(@1, "Functions may not have inout ports."); + } | block_item_decl { $$ = 0; } ;