From e1f1c82d4e7c376ba857383d7089b267ebceed40 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 9 Oct 2017 21:08:50 -0400 Subject: [PATCH] Fix -E duplicating output, bug1226. --- Changes | 2 ++ src/V3ParseImp.cpp | 4 +++- test_regress/t/t_preproc_persist.out | 3 +++ test_regress/t/t_preproc_persist.pl | 28 ++++++++++++++++++++++++++ test_regress/t/t_preproc_persist.v | 8 ++++++++ test_regress/t/t_preproc_persist2.v | 8 ++++++++ test_regress/t/t_preproc_persist_inc.v | 10 +++++++++ 7 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test_regress/t/t_preproc_persist.out create mode 100755 test_regress/t/t_preproc_persist.pl create mode 100644 test_regress/t/t_preproc_persist.v create mode 100644 test_regress/t/t_preproc_persist2.v create mode 100644 test_regress/t/t_preproc_persist_inc.v diff --git a/Changes b/Changes index 4e9b5fc0a..136e7d1f7 100644 --- a/Changes +++ b/Changes @@ -33,6 +33,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix `` expansion of empty `defines, bug1225. [Odd Magne Reitan] +**** Fix -E duplicating output, bug1226. [Odd Magne Reitan] + * Verilator 3.912 2017-09-23 diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index 5d78d0376..9bf8bb0cb 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -154,6 +154,8 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i // Parse it if (!v3Global.opt.preprocOnly()) { lexFile (modfilename); + } else { + m_ppBuffers.clear(); } } @@ -183,5 +185,5 @@ void V3Parse::parseFile(FileLine* fileline, const string& modname, bool inLibrar m_impp->parseFile(fileline, modname, inLibrary, errmsg); } void V3Parse::ppPushText(V3ParseImp* impp, const string& text) { - impp->ppPushText(text); + if (text != "") impp->ppPushText(text); } diff --git a/test_regress/t/t_preproc_persist.out b/test_regress/t/t_preproc_persist.out new file mode 100644 index 000000000..ab2780c38 --- /dev/null +++ b/test_regress/t/t_preproc_persist.out @@ -0,0 +1,3 @@ +Inside "t/t_preproc_persist.v". +Inside "t/t_preproc_persist_inc.v". +Inside "t/t_preproc_persist2.v". diff --git a/test_regress/t/t_preproc_persist.pl b/test_regress/t/t_preproc_persist.pl new file mode 100755 index 000000000..2127bc3e9 --- /dev/null +++ b/test_regress/t/t_preproc_persist.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003-2017 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"); + +my $stdout_filename = "$Self->{obj_dir}/$Self->{name}__test.vpp"; + +compile ( + # Override default flags + v_flags => [''], + v_other_filenames => ["t_preproc_persist2.v"], + verilator_flags => ["-E -P +incdir+t"], + verilator_flags2 => ['',], + verilator_flags3 => ['',], + verilator_make_gcc => 0, + make_top_shell => 0, + stdout_filename => $stdout_filename, + ); + +ok(files_identical($stdout_filename, "t/$Self->{name}.out")); + +1; diff --git a/test_regress/t/t_preproc_persist.v b/test_regress/t/t_preproc_persist.v new file mode 100644 index 000000000..0f3f45687 --- /dev/null +++ b/test_regress/t/t_preproc_persist.v @@ -0,0 +1,8 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2017 by Wilson Snyder. + +Inside `__FILE__. + +`include "t_preproc_persist_inc.v" diff --git a/test_regress/t/t_preproc_persist2.v b/test_regress/t/t_preproc_persist2.v new file mode 100644 index 000000000..0f3f45687 --- /dev/null +++ b/test_regress/t/t_preproc_persist2.v @@ -0,0 +1,8 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2017 by Wilson Snyder. + +Inside `__FILE__. + +`include "t_preproc_persist_inc.v" diff --git a/test_regress/t/t_preproc_persist_inc.v b/test_regress/t/t_preproc_persist_inc.v new file mode 100644 index 000000000..c7da7c2e9 --- /dev/null +++ b/test_regress/t/t_preproc_persist_inc.v @@ -0,0 +1,10 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2017 by Wilson Snyder. + +`ifndef COMMON_GUARD + `define COMMON_GUARD 1 +Inside `__FILE__. +`endif +