diff --git a/Changes b/Changes index 3d604cac7..d2aed905f 100644 --- a/Changes +++ b/Changes @@ -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] diff --git a/bin/verilator b/bin/verilator index 8d92efc0f..2ab688136 100755 --- a/bin/verilator +++ b/bin/verilator @@ -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. diff --git a/src/verilog.y b/src/verilog.y index afc5d9f50..6d535c6e4 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -2391,8 +2391,21 @@ statement_item: // 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 diff --git a/test_regress/t/t_func_void.v b/test_regress/t/t_func_void.v index 63d6dd657..4241c5741 100644 --- a/test_regress/t/t_func_void.v +++ b/test_regress/t/t_func_void.v @@ -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;