diff --git a/Changes b/Changes index 48cabf6b9..dbcf24c65 100644 --- a/Changes +++ b/Changes @@ -39,6 +39,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix loop error message to report line, bug513. [Jeremy Bennett] +**** Fix false UNUSED warning on file system calls. [Holger Waechtler] + * Verilator 3.833 2012/04/15 diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 142c92a58..97ea7863c 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -274,8 +274,9 @@ private: virtual void visit(AstVarRef* nodep, AstNUser*) { // Any variable UndrivenVarEntry* entryp = getEntryp (nodep->varp()); + bool fdrv = nodep->lvalue() && nodep->varp()->attrFileDescr(); // FD's are also being read from if (m_markBoth || nodep->lvalue()) entryp->drivenWhole(); - if (m_markBoth || !nodep->lvalue()) entryp->usedWhole(); + if (m_markBoth || !nodep->lvalue() || fdrv) entryp->usedWhole(); } // Don't know what black boxed calls do, assume in+out diff --git a/test_regress/t/t_lint_unused.pl b/test_regress/t/t_lint_unused.pl new file mode 100755 index 000000000..1deb80a7b --- /dev/null +++ b/test_regress/t/t_lint_unused.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2008 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. + +$Self->{vlt} or $Self->skip("Verilator only test"); + +compile ( + v_flags2 => ["--lint-only --bbox-sys --bbox-unsup -Wall -Wno-DECLFILENAME"], + fails=>0, + verilator_make_gcc => 0, + make_top_shell => 0, + make_main => 0, + ); + +ok(1); +1; + diff --git a/test_regress/t/t_lint_unused.v b/test_regress/t/t_lint_unused.v new file mode 100644 index 000000000..ad4a23147 --- /dev/null +++ b/test_regress/t/t_lint_unused.v @@ -0,0 +1,60 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2010 by Wilson Snyder. + +module t (/*AUTOARG*/ + // Outputs + out, + // Inputs + in + ); + + input in; // inputs don't get flagged as undriven + output out; // outputs don't get flagged as unused + + sub sub (); + + // Check we don't warn about unused UDP signals + udp_mux2 udpsub (out, in, in, in); + + // Check ignoreds mark as used + reg sysused; + initial $bboxed(sysused); + + // Check file IO. The fopen is the "driver" all else a usage. + integer infile; + integer outfile; + initial begin + outfile = $fopen("obj_dir/t_lint_unused_bad/open.log", "w"); + $fwrite(outfile, "1\n"); + $fclose(outfile); + infile = $fopen("obj_dir/t_lint_unused_bad/open.log", "r"); + if ($fgetc(infile) != "1") begin end + end + + wire _unused_ok; + +endmodule + +module sub; + + wire pub /*verilator public*/; // Ignore publics + + localparam THREE = 3; + +endmodule + +primitive udp_mux2 (q, a, b, s); + output q; + input a, b, s; + table + //a b s : out + 1 ? 0 : 1 ; + 0 ? 0 : 0 ; + ? 1 1 : 1 ; + ? 0 1 : 0 ; + 0 0 x : 0 ; + 1 1 x : 1 ; + endtable +endprimitive diff --git a/test_regress/t/t_lint_unused_bad.v b/test_regress/t/t_lint_unused_bad.v index 77443b028..9cdacf34b 100644 --- a/test_regress/t/t_lint_unused_bad.v +++ b/test_regress/t/t_lint_unused_bad.v @@ -3,27 +3,10 @@ // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2010 by Wilson Snyder. -module t (/*AUTOARG*/ - // Outputs - out, - // Inputs - in - ); - - input in; // inputs don't get flagged as undriven - output out; // outputs don't get flagged as unused +module t (/*AUTOARG*/); sub sub (); - // Check we don't warn about unused UDP signals - udp_mux2 udpsub (out, in, in, in); - - // Check ignoreds mark as used - reg sysused; - initial $bboxed(sysused); - - wire _unused_ok; - endmodule module sub; @@ -53,17 +36,3 @@ module sub; if (0 && mixed[1:0] != 0) begin end end endmodule - -primitive udp_mux2 (q, a, b, s); - output q; - input a, b, s; - table - //a b s : out - 1 ? 0 : 1 ; - 0 ? 0 : 0 ; - ? 1 1 : 1 ; - ? 0 1 : 0 ; - 0 0 x : 0 ; - 1 1 x : 1 ; - endtable -endprimitive