Improve error message on assignment to an array or array slice (issue #562).

This is valid SystemVerilog, but not something we support yet.
This commit is contained in:
Martin Whitaker 2021-11-12 21:43:24 +00:00
parent 61aed6882c
commit 71c36d1289
1 changed files with 11 additions and 5 deletions

View File

@ -259,12 +259,18 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
use_sel = name_tail.index.back().sel; use_sel = name_tail.index.back().sel;
// Special case: The l-value is an entire memory, or array // Special case: The l-value is an entire memory, or array
// slice. This is, in fact, an error in l-values. Detect the // slice. Detect the situation by noting if the index count
// situation by noting if the index count is less than the // is less than the array dimensions (unpacked).
// array dimensions (unpacked).
if (reg->unpacked_dimensions() > name_tail.index.size()) { if (reg->unpacked_dimensions() > name_tail.index.size()) {
cerr << get_fileline() << ": error: Cannot assign to array " if (gn_system_verilog()) {
<< path_ << ". Did you forget a word index?" << endl; cerr << get_fileline() << ": sorry: Assignment to an entire"
" array or to an array slice is not yet supported."
<< endl;
} else {
cerr << get_fileline() << ": error: Assignment to an entire"
" array or to an array slice requires SystemVerilog."
<< endl;
}
des->errors += 1; des->errors += 1;
return 0; return 0;
} }