From adf1de45de8bdfdea6030763cc9298c96b416783 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 21 Feb 2023 16:45:35 -0500 Subject: [PATCH] With -Wpedantic change ASSIGNIN to a warning --- docs/guide/exe_verilator.rst | 2 ++ src/V3Options.cpp | 5 ++++- test_regress/t/t_var_in_assign_pedantic.pl | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 test_regress/t/t_var_in_assign_pedantic.pl diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 7027fc1f0..0a4b90249 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -1530,6 +1530,8 @@ Summary: :command:`gcc -Wpedantic`. Rarely used, and intended only for strict compliance tests. + This option changes :option:`ASSIGNIN` from an error to a warning. + .. option:: -Wwarn- Enables the specified warning message. diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 7fd603ac9..faec6ba50 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1526,7 +1526,10 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char }); DECL_OPTION("-vpi", OnOff, &m_vpi); - DECL_OPTION("-Wpedantic", OnOff, &m_pedantic); + DECL_OPTION("-Wpedantic", CbCall, [this]() { + m_pedantic = true; + V3Error::pretendError(V3ErrorCode::ASSIGNIN, false); + }); DECL_OPTION("-Wall", CbCall, []() { FileLine::globalWarnLintOff(false); FileLine::globalWarnStyleOff(false); diff --git a/test_regress/t/t_var_in_assign_pedantic.pl b/test_regress/t/t_var_in_assign_pedantic.pl new file mode 100755 index 000000000..205a9bca8 --- /dev/null +++ b/test_regress/t/t_var_in_assign_pedantic.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2005 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. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(vlt => 1); + +top_filename("t/t_var_in_assign_bad.v"); + +lint( + verilator_flags2 => ['-Wpedantic -Wno-fatal'], + ); + +ok(1); +1;