Fix error on `with` to give UNSUPPORTED (#6134)

This commit is contained in:
Wilson Snyder 2025-07-27 16:10:19 -04:00
parent 7c71bdf2d6
commit 64a82508f2
2 changed files with 19 additions and 14 deletions

View File

@ -3399,11 +3399,16 @@ class WidthVisitor final : public VNVisitor {
}
return nullptr;
}
void methodOkArguments(AstNodeFTaskRef* nodep, int minArg, int maxArg) {
void methodOkArguments(AstNodeFTaskRef* nodep, int minArg, int maxArg,
bool withUnsup = false) {
int narg = 0;
for (AstNode* argp = nodep->pinsp(); argp; argp = argp->nextp()) {
if (VN_IS(argp, With)) {
argp->v3error("'with' not legal on this method");
if (withUnsup) {
argp->v3warn(E_UNSUPPORTED, "Unsupported: 'with' on this method");
} else {
argp->v3error("'with' not legal on this method");
}
// Delete all arguments as nextp() otherwise dangling
VL_DO_DANGLING(pushDeletep(argp->unlinkFrBackWithNext()), argp);
break;
@ -4266,7 +4271,7 @@ class WidthVisitor final : public VNVisitor {
}
if (methodId) {
methodOkArguments(nodep, 0, 0);
methodOkArguments(nodep, 0, 0, true /*withUnsup*/);
FileLine* const fl = nodep->fileline();
AstNodeExpr* newp = nullptr;
for (int i = 0; i < adtypep->elementsConst(); ++i) {

View File

@ -1,22 +1,22 @@
%Error: t/t_array_method_unsup.v:23:17: 'with' not legal on this method
: ... note: In instance 't'
%Error-UNSUPPORTED: t/t_array_method_unsup.v:23:17: Unsupported: 'with' on this method
: ... note: In instance 't'
23 | i = q.sum with (item + 1); do if ((i) !== (32'h11)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_array_method_unsup.v",23, (i), (32'h11)); $stop; end while(0);;
| ^~~~
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: t/t_array_method_unsup.v:24:21: 'with' not legal on this method
: ... note: In instance 't'
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error-UNSUPPORTED: t/t_array_method_unsup.v:24:21: Unsupported: 'with' on this method
: ... note: In instance 't'
24 | i = q.product with (item + 1); do if ((i) !== (32'h168)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_array_method_unsup.v",24, (i), (32'h168)); $stop; end while(0);;
| ^~~~
%Error: t/t_array_method_unsup.v:27:17: 'with' not legal on this method
: ... note: In instance 't'
%Error-UNSUPPORTED: t/t_array_method_unsup.v:27:17: Unsupported: 'with' on this method
: ... note: In instance 't'
27 | i = q.and with (item + 1); do if ((i) !== (32'b1001)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_array_method_unsup.v",27, (i), (32'b1001)); $stop; end while(0);;
| ^~~~
%Error: t/t_array_method_unsup.v:28:16: 'with' not legal on this method
: ... note: In instance 't'
%Error-UNSUPPORTED: t/t_array_method_unsup.v:28:16: Unsupported: 'with' on this method
: ... note: In instance 't'
28 | i = q.or with (item + 1); do if ((i) !== (32'b1111)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_array_method_unsup.v",28, (i), (32'b1111)); $stop; end while(0);;
| ^~~~
%Error: t/t_array_method_unsup.v:29:17: 'with' not legal on this method
: ... note: In instance 't'
%Error-UNSUPPORTED: t/t_array_method_unsup.v:29:17: Unsupported: 'with' on this method
: ... note: In instance 't'
29 | i = q.xor with (item + 1); do if ((i) !== (32'hb)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", "t/t_array_method_unsup.v",29, (i), (32'hb)); $stop; end while(0);;
| ^~~~
%Error: Exiting due to