Support void' cast on functions called as tasks, bug1383.

This commit is contained in:
Wilson Snyder 2019-03-10 15:12:20 -04:00
parent 539a773ea7
commit d9b33d74a4
4 changed files with 27 additions and 7 deletions

View File

@ -8,7 +8,9 @@ The contributors that suggested a given feature are shown in []. Thanks!
*** Support $fread. [Leendert van Doorn]
*** Add IGNOREDRETURN warning.
*** Support void' cast on functions called as tasks, bug1383. [Al Grant]
*** Add IGNOREDRETURN warning, bug1383.
**** Report PORTSHORT errors on concat constants, bug 1400. [Will Korteland]

View File

@ -3583,7 +3583,12 @@ correctly.
=item IGNOREDRETURN
Warns that a non-void function is being called as a task, and hence the
return value is being ignored. This warning is required by IEEE.
return value is being ignored.
This warning is required by IEEE. The portable way to suppress this warning
(in SystemVerilog) is to use a void cast, e.g.
void'(function_being_called_as_task());
Ignoring this warning will only suppress the lint check, it will simulate
correctly.

View File

@ -2391,8 +2391,21 @@ statement_item<nodep>: // IEEE: statement_item
// // Below under expr
//
// // IEEE: subroutine_call_statement
//UNSUP yVOID yP_TICK '(' function_subroutine_callNoMethod ')' ';' { }
//UNSUP yVOID yP_TICK '(' expr '.' function_subroutine_callNoMethod ')' ';' { }
// // IEEE says we then expect a function call
// // (function_subroutine_callNoMethod), but rest of
// // the code expects an AstTask when used as a statement,
// // so parse as if task
// // Alternative would be shim with new AstVoidStmt.
| yVOID yP_TICK '(' task_subroutine_callNoMethod ')' ';'
{ $$ = $4;
FileLine* newfl = new FileLine($$->fileline());
newfl->warnOff(V3ErrorCode::IGNOREDRETURN, true);
$$->fileline(newfl); }
| yVOID yP_TICK '(' expr '.' task_subroutine_callNoMethod ')' ';'
{ $$ = new AstDot($5, $4, $6);
FileLine* newfl = new FileLine($6->fileline());
newfl->warnOff(V3ErrorCode::IGNOREDRETURN, true);
$6->fileline(newfl); }
// // Expr included here to resolve our not knowing what is a method call
// // Expr here must result in a subroutine_call
| task_subroutine_callNoMethod ';' { $$ = $1; }
@ -3965,7 +3978,7 @@ void V3ParseGrammar::argWrapList(AstNodeFTaskRef* nodep) {
}
AstNode* V3ParseGrammar::createSupplyExpr(FileLine* fileline, string name, int value) {
FileLine* newfl = new FileLine (fileline);
FileLine* newfl = new FileLine(fileline);
newfl->warnOff(V3ErrorCode::WIDTH, true);
AstNode* nodep = new AstConst(newfl, V3Number(newfl));
// Adding a NOT is less work than figuring out how wide to make it

View File

@ -26,8 +26,8 @@ module t (clk);
// verilator lint_on IGNOREDRETURN
if (side_effect != 33) $stop;
//
// void'f1(30);
// if (side_effect != 64) $stop;
void'(f1(30));
if (side_effect != 64) $stop;
//
$write("*-* All Finished *-*\n");
$finish;