Fix null pointer dereference in debug output.

Don't display an elaborated for loop initial assignment if elaboration
has failed. Also remove duplicated message.
This commit is contained in:
Martin Whitaker 2015-04-13 16:31:28 +01:00
parent 560b9530fd
commit ccf7c042c9
1 changed files with 1 additions and 8 deletions

View File

@ -4889,7 +4889,7 @@ NetProc* PForStatement::elaborate(Design*des, NetScope*scope) const
sig->data_type(), sig->vector_width(), sig->data_type(), sig->vector_width(),
expr1_); expr1_);
if (debug_elaborate) { if (debug_elaborate && initial_expr) {
cerr << get_fileline() << ": debug: FOR initial assign: " cerr << get_fileline() << ": debug: FOR initial assign: "
<< sig->name() << " = " << *initial_expr << endl; << sig->name() << " = " << *initial_expr << endl;
} }
@ -4900,18 +4900,11 @@ NetProc* PForStatement::elaborate(Design*des, NetScope*scope) const
reported so it's OK that the netlist is bogus. */ reported so it's OK that the netlist is bogus. */
NetProc*sub = statement_->elaborate(des, scope); NetProc*sub = statement_->elaborate(des, scope);
/* Now elaborate the for_step statement. I really should do /* Now elaborate the for_step statement. I really should do
some error checking here to make sure the step statement some error checking here to make sure the step statement
really does step the variable. */ really does step the variable. */
if (debug_elaborate) {
cerr << get_fileline() << ": debug: Elaborate for_step statement "
<< sig->name() << " = " << *initial_expr << endl;
}
NetProc*step = step_->elaborate(des, scope); NetProc*step = step_->elaborate(des, scope);
/* Elaborate the condition expression. Try to evaluate it too, /* Elaborate the condition expression. Try to evaluate it too,
in case it is a constant. This is an interesting case in case it is a constant. This is an interesting case
worthy of a warning. */ worthy of a warning. */