diff --git a/vhdlpp/expression_elaborate.cc b/vhdlpp/expression_elaborate.cc index 348b47cea..76850aafd 100644 --- a/vhdlpp/expression_elaborate.cc +++ b/vhdlpp/expression_elaborate.cc @@ -795,7 +795,9 @@ const VType*ExpFunc::probe_type(Entity*, ScopeBase*scope) const prog = library_find_subprogram(name_); if(!prog) { - cerr << get_fileline() << ": sorry: VHDL function " << name_ << " not yet implemented" << endl; + cerr << get_fileline() << ": sorry: could not find function "; + emit_subprogram_sig(cerr, name_, arg_types); + cerr << endl; ivl_assert(*this, false); } @@ -812,8 +814,13 @@ int ExpFunc::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*) if(!prog) prog = library_find_subprogram(name_); - ivl_assert(*this, def_==0); def_ = prog; + if(!def_) { + cerr << get_fileline() << ": error: could not find function "; + emit_subprogram_sig(cerr, name_, arg_types); + cerr << endl; + return 1; + } // Elaborate arguments for (size_t idx = 0; idx < argv_.size(); ++idx) { @@ -828,11 +835,6 @@ int ExpFunc::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*) name_ = def_->name(); } - if(!def_) { - cerr << get_fileline() << ": error: could not find function " << name_ << endl; - ++errors; - } - return errors; } diff --git a/vhdlpp/sequential_elaborate.cc b/vhdlpp/sequential_elaborate.cc index d3e1e493a..4d67daa65 100644 --- a/vhdlpp/sequential_elaborate.cc +++ b/vhdlpp/sequential_elaborate.cc @@ -183,7 +183,12 @@ int ProcedureCall::elaborate(Entity*ent, ScopeBase*scope) if(!def_) def_ = library_find_subprogram(name_); - assert(def_); + if(!def_) { + cerr << get_fileline() << ": error: could not find procedure "; + emit_subprogram_sig(cerr, name_, arg_types); + cerr << endl; + return 1; + } // Elaborate arguments size_t idx = 0; diff --git a/vhdlpp/subprogram.h b/vhdlpp/subprogram.h index ba10f6e56..6eb0446c9 100644 --- a/vhdlpp/subprogram.h +++ b/vhdlpp/subprogram.h @@ -169,4 +169,8 @@ class SubprogramBuiltin : public SubprogramStdHeader perm_string sv_name_; }; +// Helper function to print out a human-readable function signature. +void emit_subprogram_sig(std::ostream&out, perm_string name, + const std::list&arg_types); + #endif /* IVL_subprogram_H */ diff --git a/vhdlpp/subprogram_emit.cc b/vhdlpp/subprogram_emit.cc index 18ab855a3..0aa02973e 100644 --- a/vhdlpp/subprogram_emit.cc +++ b/vhdlpp/subprogram_emit.cc @@ -142,3 +142,23 @@ int SubprogramBuiltin::emit_name(const std::vector&, out << sv_name_; return 0; } + +void emit_subprogram_sig(ostream&out, perm_string name, + const list&arg_types) +{ + out << name << "("; + bool first = true; + for(list::const_iterator it = arg_types.begin(); + it != arg_types.end(); ++it) { + if(first) + first = false; + else + out << ", "; + + if(*it) + (*it)->write_to_stream(out); + else + out << ""; + } + out << ")"; +}