V0.8: Don't crash on invalid input.

This patch mirrors what was done in development to prevent a crash
when given invalid input.
This commit is contained in:
Cary R 2008-11-21 15:37:14 -08:00 committed by Stephen Williams
parent e8bb9b1f76
commit 322bbed7c7
2 changed files with 11 additions and 2 deletions

View File

@ -1977,8 +1977,8 @@ NetProc* PEventStatement::elaborate_st(Design*des, NetScope*scope,
if (synthesis) rem_out = true;
NexusSet*nset = enet->nex_input(rem_out);
if (nset == 0) {
cerr << get_line() << ": internal error: No NexusSet"
<< " from statement." << endl;
cerr << get_line() << ": error: Unable to elaborate:"
<< endl;
enet->dump(cerr, 6);
des->errors += 1;
return enet;

View File

@ -65,9 +65,14 @@ NexusSet* NetEBitSel::nex_input(bool rem_out)
NexusSet* NetEConcat::nex_input(bool rem_out)
{
if (parms_[0] == NULL) return NULL;
NexusSet*result = parms_[0]->nex_input(rem_out);
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
NexusSet*tmp = parms_[idx]->nex_input(rem_out);
if (tmp == NULL) {
delete result;
return NULL;
}
result->add(*tmp);
delete tmp;
}
@ -116,6 +121,10 @@ NexusSet* NetESelect::nex_input(bool rem_out)
{
NexusSet*result = base_? base_->nex_input(rem_out) : new NexusSet();
NexusSet*tmp = expr_->nex_input(rem_out);
if (tmp == NULL) {
delete result;
return NULL;
}
result->add(*tmp);
delete tmp;
return result;