diff --git a/elab_expr.cc b/elab_expr.cc index 037b04da2..29a39c016 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -433,6 +433,15 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope, bool) const << "may not be undefined (" << rep->value() << ")." << endl; des->errors += 1; + return 0; + } + + if (rep->value().is_negative()) { + cerr << get_line() << ": error: Concatenation repeat " + << "may not be negative (" << rep->value().as_long() + << ")." << endl; + des->errors += 1; + return 0; } repeat = rep; diff --git a/elab_net.cc b/elab_net.cc index 098e3f7a7..8f5a311db 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -1349,6 +1349,14 @@ NetNet* PEConcat::elaborate_net(Design*des, NetScope*scope, des->errors += 1; return 0; } + + if (erep->value().is_negative()) { + cerr << get_line() << ": error: Concatenation repeat " + << "may not be negative (" << erep->value().as_long() + << ")." << endl; + des->errors += 1; + return 0; + } } /* The operands of the concatenation must contain all