From aca4ab015f967d7878e718442e44e601eff9374f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 19 Apr 2010 19:38:22 -0400 Subject: [PATCH] Fix removing if assigned to unused var, bug248. --- Changes | 2 ++ src/V3Dead.cpp | 5 +---- test_regress/t/t_sys_file_scan.v | 9 +++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index 1370bd0d4..d4988feaa 100644 --- a/Changes +++ b/Changes @@ -17,6 +17,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix bit reductions on multi-packed dimensions, bug227. [by Bryon Bradley] +**** Fix removing $fscanf if assigned to unused var, bug248. [Ashutosh Das] + **** Fix "make install" with configure outside srcdir. [Stefan Wallentowitz] **** Fix loop unroller out of memory; change --unroll-stmts. [Ashutosh Das] diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index f9195747b..222474d52 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -145,13 +145,10 @@ private: nodep->lhsp()->iterateAndNext(*this); } } - virtual void visit(AstUCFunc* nodep, AstNUser*) { - m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment - nodep->iterateChildren(*this); - } //----- virtual void visit(AstNode* nodep, AstNUser*) { + if (nodep->isOutputter()) m_sideEffect=true; nodep->iterateChildren(*this); } diff --git a/test_regress/t/t_sys_file_scan.v b/test_regress/t/t_sys_file_scan.v index 79aa0073e..e94e580ea 100644 --- a/test_regress/t/t_sys_file_scan.v +++ b/test_regress/t/t_sys_file_scan.v @@ -14,9 +14,14 @@ module t; outfile = $fopen("obj_dir/t_sys_file_scan/t_sys_file_scan_test.log", "w"); count = 1234; - $display("count == %d, infile %d, outfile %d", count, infile, outfile); +`ifdef TEST_VERBOSE + $display("-count == %d, infile %d, outfile %d", count, infile, outfile); +`endif count = $fscanf(infile, "%d\n", a); - $display("count == %d, infile %d, outfile %d", count, infile, outfile); +`ifdef TEST_VERBOSE + // Ifdefing this out gave bug248 + $display("-count == %d, infile %d, outfile %d", count, infile, outfile); +`endif $fwrite(outfile, "# a\n"); $fwrite(outfile, "%d\n", a); $fclose(infile);