Add IGNOREDRETURN warning.
This commit is contained in:
parent
b1831d7e33
commit
539a773ea7
2
Changes
2
Changes
|
@ -8,6 +8,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||||
|
|
||||||
*** Support $fread. [Leendert van Doorn]
|
*** Support $fread. [Leendert van Doorn]
|
||||||
|
|
||||||
|
*** Add IGNOREDRETURN warning.
|
||||||
|
|
||||||
**** Report PORTSHORT errors on concat constants, bug 1400. [Will Korteland]
|
**** Report PORTSHORT errors on concat constants, bug 1400. [Will Korteland]
|
||||||
|
|
||||||
**** Fix VERILATOR_GDB being ignored, msg2860. [Yu Sheng Lin]
|
**** Fix VERILATOR_GDB being ignored, msg2860. [Yu Sheng Lin]
|
||||||
|
|
|
@ -3580,6 +3580,14 @@ code to a case statement, or a SystemVerilog 'unique if' or 'priority if'.
|
||||||
Disabled by default as this is a code style warning; it will simulate
|
Disabled by default as this is a code style warning; it will simulate
|
||||||
correctly.
|
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.
|
||||||
|
|
||||||
|
Ignoring this warning will only suppress the lint check, it will simulate
|
||||||
|
correctly.
|
||||||
|
|
||||||
=item IMPERFECTSCH
|
=item IMPERFECTSCH
|
||||||
|
|
||||||
Warns that the scheduling of the model is not absolutely perfect, and some
|
Warns that the scheduling of the model is not absolutely perfect, and some
|
||||||
|
|
|
@ -78,7 +78,8 @@ public:
|
||||||
ENDLABEL, // End lable name mismatch
|
ENDLABEL, // End lable name mismatch
|
||||||
GENCLK, // Generated Clock
|
GENCLK, // Generated Clock
|
||||||
IFDEPTH, // If statements too deep
|
IFDEPTH, // If statements too deep
|
||||||
IMPERFECTSCH, // Imperfect schedule (disabled by default)
|
IGNOREDRETURN, // Ignoring return value (funcation as task)
|
||||||
|
IMPERFECTSCH, // Imperfect schedule (disabled by default)
|
||||||
IMPLICIT, // Implicit wire
|
IMPLICIT, // Implicit wire
|
||||||
IMPORTSTAR, // Import::* in $unit
|
IMPORTSTAR, // Import::* in $unit
|
||||||
IMPURE, // Impure function not being inlined
|
IMPURE, // Impure function not being inlined
|
||||||
|
@ -139,7 +140,8 @@ public:
|
||||||
"CMPCONST", "COLONPLUS", "COMBDLY", "CONTASSREG",
|
"CMPCONST", "COLONPLUS", "COMBDLY", "CONTASSREG",
|
||||||
"DEFPARAM", "DECLFILENAME",
|
"DEFPARAM", "DECLFILENAME",
|
||||||
"ENDLABEL", "GENCLK",
|
"ENDLABEL", "GENCLK",
|
||||||
"IFDEPTH", "IMPERFECTSCH", "IMPLICIT", "IMPORTSTAR", "IMPURE",
|
"IFDEPTH", "IGNOREDRETURN",
|
||||||
|
"IMPERFECTSCH", "IMPLICIT", "IMPORTSTAR", "IMPURE",
|
||||||
"INCABSPATH", "INFINITELOOP", "INITIALDLY",
|
"INCABSPATH", "INFINITELOOP", "INITIALDLY",
|
||||||
"LITENDIAN", "MODDUP",
|
"LITENDIAN", "MODDUP",
|
||||||
"MULTIDRIVEN",
|
"MULTIDRIVEN",
|
||||||
|
|
|
@ -1170,11 +1170,15 @@ private:
|
||||||
nodep->replaceWith(outrefp);
|
nodep->replaceWith(outrefp);
|
||||||
// Insert new statements
|
// Insert new statements
|
||||||
visitp = insertBeforeStmt(nodep, beginp);
|
visitp = insertBeforeStmt(nodep, beginp);
|
||||||
} else {
|
} else {
|
||||||
// outvscp maybe non-NULL if calling a function in a taskref,
|
if (nodep->taskp()->isFunction()) {
|
||||||
// but if so we want to simply ignore the function result
|
nodep->v3warn(IGNOREDRETURN,
|
||||||
nodep->replaceWith(beginp);
|
"Ignoring return value of non-void function (IEEE 2017 13.4.1)");
|
||||||
}
|
}
|
||||||
|
// outvscp maybe non-NULL if calling a function in a taskref,
|
||||||
|
// but if so we want to simply ignore the function result
|
||||||
|
nodep->replaceWith(beginp);
|
||||||
|
}
|
||||||
// Cleanup
|
// Cleanup
|
||||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||||
UINFO(4," FTask REF Done.\n");
|
UINFO(4," FTask REF Done.\n");
|
||||||
|
|
|
@ -46,7 +46,9 @@ module t (/*AUTOARG*/);
|
||||||
// Test loop
|
// Test loop
|
||||||
initial begin
|
initial begin
|
||||||
// bug963
|
// bug963
|
||||||
|
// verilator lint_off IGNOREDRETURN
|
||||||
dpii_clear();
|
dpii_clear();
|
||||||
|
// verilator lint_on IGNOREDRETURN
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i=0; i<64; i++) begin
|
for (i=0; i<64; i++) begin
|
||||||
if (i[0])
|
if (i[0])
|
||||||
|
|
|
@ -50,12 +50,15 @@ module t;
|
||||||
if (n !== 10) $stop;
|
if (n !== 10) $stop;
|
||||||
|
|
||||||
// Functions called as tasks
|
// Functions called as tasks
|
||||||
|
// verilator lint_off IGNOREDRETURN
|
||||||
rglobal = 32'h4;
|
rglobal = 32'h4;
|
||||||
if (inc_and_return(32'h2) != 32'h6) $stop;
|
if (inc_and_return(32'h2) != 32'h6) $stop;
|
||||||
if (rglobal !== 32'h6) $stop;
|
if (rglobal !== 32'h6) $stop;
|
||||||
rglobal = 32'h6;
|
rglobal = 32'h6;
|
||||||
|
|
||||||
inc_and_return(32'h3);
|
inc_and_return(32'h3);
|
||||||
if (rglobal !== 32'h9) $stop;
|
if (rglobal !== 32'h9) $stop;
|
||||||
|
// verilator lint_on IGNOREDRETURN
|
||||||
|
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
module t (/*AUTOARG*/);
|
module t (/*AUTOARG*/);
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
|
// verilator lint_off IGNOREDRETURN
|
||||||
func(0, 1'b1);
|
func(0, 1'b1);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
scenarios(simulator => 1);
|
||||||
|
|
||||||
|
compile(
|
||||||
|
);
|
||||||
|
|
||||||
|
execute(
|
||||||
|
check_finished => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
|
@ -0,0 +1,36 @@
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2003 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t (clk);
|
||||||
|
input clk;
|
||||||
|
|
||||||
|
int side_effect;
|
||||||
|
|
||||||
|
function int f1;
|
||||||
|
input int in;
|
||||||
|
f1 = in + 1;
|
||||||
|
side_effect += in + 1;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
int got;
|
||||||
|
side_effect = 1;
|
||||||
|
//
|
||||||
|
got = f1(10);
|
||||||
|
if (got != 11) $stop;
|
||||||
|
if (side_effect != 12) $stop;
|
||||||
|
// verilator lint_off IGNOREDRETURN
|
||||||
|
f1(20);
|
||||||
|
// verilator lint_on IGNOREDRETURN
|
||||||
|
if (side_effect != 33) $stop;
|
||||||
|
//
|
||||||
|
// void'f1(30);
|
||||||
|
// if (side_effect != 64) $stop;
|
||||||
|
//
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
|
@ -0,0 +1,3 @@
|
||||||
|
%Warning-IGNOREDRETURN: t/t_func_void_bad.v:25: Ignoring return value of non-void function (IEEE 2017 13.4.1)
|
||||||
|
%Warning-IGNOREDRETURN: Use "/* verilator lint_off IGNOREDRETURN */" and lint_on around source to disable this message.
|
||||||
|
%Error: Exiting due to
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
scenarios(simulator => 1);
|
||||||
|
|
||||||
|
compile(
|
||||||
|
fails => 1,
|
||||||
|
expect_filename => $Self->{golden_filename},
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
|
@ -0,0 +1,35 @@
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2003 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t (clk);
|
||||||
|
input clk;
|
||||||
|
|
||||||
|
int side_effect;
|
||||||
|
|
||||||
|
function int f1;
|
||||||
|
input int in;
|
||||||
|
f1 = in + 1;
|
||||||
|
side_effect += in + 1;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
int got;
|
||||||
|
side_effect = 1;
|
||||||
|
//
|
||||||
|
got = f1(10);
|
||||||
|
if (got != 11) $stop;
|
||||||
|
if (side_effect != 12) $stop;
|
||||||
|
//
|
||||||
|
f1(20);
|
||||||
|
if (side_effect != 33) $stop;
|
||||||
|
//
|
||||||
|
// void'f1(30);
|
||||||
|
// if (side_effect != 64) $stop;
|
||||||
|
//
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
Loading…
Reference in New Issue