Tests: test class IGNOREDRETURN.

This commit is contained in:
Wilson Snyder 2024-09-08 15:09:44 -04:00
parent 1e7611edea
commit 434896d50c
2 changed files with 16 additions and 19 deletions

View File

@ -1,6 +1,9 @@
%Warning-IGNOREDRETURN: t/t_func_void_bad.v:26:7: Ignoring return value of non-void function (IEEE 1800-2023 13.4.1)
26 | f1(20);
%Warning-IGNOREDRETURN: t/t_func_void_bad.v:21:7: Ignoring return value of non-void function (IEEE 1800-2023 13.4.1)
21 | f1();
| ^~
... For warning description see https://verilator.org/warn/IGNOREDRETURN?v=latest
... Use "/* verilator lint_off IGNOREDRETURN */" and lint_on around source to disable this message.
%Warning-IGNOREDRETURN: t/t_func_void_bad.v:24:9: Ignoring return value of non-void function (IEEE 1800-2023 13.4.1)
24 | c.fi();
| ^~
%Error: Exiting due to

View File

@ -4,30 +4,24 @@
// any use, without warranty, 2003 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t (clk);
input clk;
int side_effect;
class Cls;
function int fi();
return 10;
endfunction
endclass
module t;
function int f1;
input int in;
f1 = in + 1;
side_effect += in + 1;
return 20;
endfunction
initial begin
int got;
side_effect = 1;
Cls c;
//
got = f1(10);
if (got != 11) $stop;
if (side_effect != 12) $stop;
f1(); // Bad - ignored result
//
f1(20);
if (side_effect != 33) $stop;
//
// void'f1(30);
// if (side_effect != 64) $stop;
c = new;
c.fi(); // Bad - ignored result
//
$write("*-* All Finished *-*\n");
$finish;