Print error if foreach loops variables exceed number of array dimensions
Currently when the number of loop variables in a foreach loop is larger than the number of array dimensions an assertion is triggered. Turn this into a error message instead for graceful error reporting. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
3509cc86f8
commit
eaea5e7939
10
elaborate.cc
10
elaborate.cc
|
|
@ -5380,7 +5380,6 @@ NetProc* PForeach::elaborate_static_array_(Design*des, NetScope*scope,
|
|||
}
|
||||
|
||||
ivl_assert(*this, index_vars_.size() > 0);
|
||||
ivl_assert(*this, dims.size() >= index_vars_.size());
|
||||
|
||||
NetProc*sub;
|
||||
if (statement_)
|
||||
|
|
@ -5389,6 +5388,15 @@ NetProc* PForeach::elaborate_static_array_(Design*des, NetScope*scope,
|
|||
sub = new NetBlock(NetBlock::SEQU, 0);
|
||||
NetForLoop*stmt = 0;
|
||||
|
||||
if (index_vars_.size() > dims.size()) {
|
||||
delete sub;
|
||||
cerr << get_fileline() << ": error: Number of foreach loop indices"
|
||||
<< "(" << index_vars_.size() << ") must not exceed number of "
|
||||
<< "array dimensions (" << dims.size() << ")." << endl;
|
||||
des->errors++;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (int idx_idx = index_vars_.size()-1 ; idx_idx >= 0 ; idx_idx -= 1) {
|
||||
const netrange_t&idx_range = dims[idx_idx];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue