From 3d6e8e9eb02e338c391b42c1e8da30042a334662 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 23 Nov 2019 10:39:36 -0500 Subject: [PATCH] Add -Wno-context. Signed-off-by: Wilson Snyder --- Changes | 2 +- bin/verilator | 8 ++++++++ src/V3FileLine.cpp | 1 + src/V3Options.cpp | 12 ++++++++---- src/V3Options.h | 2 ++ src/verilog.y | 2 +- test_regress/t/t_flag_context_bad.out | 6 ++++++ test_regress/t/t_flag_context_bad.pl | 19 +++++++++++++++++++ test_regress/t/t_flag_context_bad.v | 10 ++++++++++ 9 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 test_regress/t/t_flag_context_bad.out create mode 100755 test_regress/t/t_flag_context_bad.pl create mode 100644 test_regress/t/t_flag_context_bad.v diff --git a/Changes b/Changes index 0e0b470fc..233703046 100644 --- a/Changes +++ b/Changes @@ -12,7 +12,7 @@ The contributors that suggested a given feature are shown in []. Thanks! *** Support shortreal as real, with a SHORTREAL warning. -**** Add -Wpedantic for compliance testing. +**** Add -Wpedantic and -Wno-context for compliance testing. **** Add error on redefining preprocessor directives. [Piotr Binkowski] diff --git a/bin/verilator b/bin/verilator index f259a021d..043975b35 100755 --- a/bin/verilator +++ b/bin/verilator @@ -398,6 +398,7 @@ detailed descriptions in L for more information. -Werror- Convert warnings to errors -Wfuture- Disable unknown message warnings -Wno- Disable warning + -Wno-context Disable source context on warnings -Wno-fatal Disable fatal exit on warnings -Wno-lint Disable all lint warnings -Wno-style Disable all style warnings @@ -1532,6 +1533,13 @@ Disable the specified warning message, or in some cases where noted here disable an error. This will override any lint_on directives in the source, i.e. the warning will still not be printed. +=item -Wno-context + +Disable showing the suspected context of the warning message by quoting the +source text at the suspected location. This is used to appease tools which +process the error messages may get confused by lines from the original +source. + =item -Wno-fatal When warnings are detected, print them, but do not exit the simulator. diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index 88c931ba0..9d4ca503c 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -379,6 +379,7 @@ string FileLine::prettySource() const { string FileLine::warnContext(bool secondary) const { V3Error::errorContexted(true); + if (!v3Global.opt.context()) return ""; string out = ""; if (firstLineno()==lastLineno() && firstColumn()) { string sourceLine = prettySource(); diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 5fcbbe4b4..877ecc639 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1050,16 +1050,19 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char addFuture(msg); } else if (!strncmp (sw, "-Wno-", 5)) { - if (!strcmp(sw, "-Wno-lint")) { + if (!strcmp(sw, "-Wno-context")) { + m_context = false; + } + else if (!strcmp(sw, "-Wno-fatal")) { + V3Error::warnFatal(false); + } + else if (!strcmp(sw, "-Wno-lint")) { FileLine::globalWarnLintOff(true); FileLine::globalWarnStyleOff(true); } else if (!strcmp(sw, "-Wno-style")) { FileLine::globalWarnStyleOff(true); } - else if (!strcmp(sw, "-Wno-fatal")) { - V3Error::warnFatal(false); - } else { string msg = sw+strlen("-Wno-"); if (!(FileLine::globalWarnOff(msg, true))) { @@ -1437,6 +1440,7 @@ V3Options::V3Options() { m_bboxUnsup = false; m_cdc = false; m_cmake = false; + m_context = true; m_coverageLine = false; m_coverageToggle = false; m_coverageUnderscore = false; diff --git a/src/V3Options.h b/src/V3Options.h index b8e8be77c..b924fd587 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -142,6 +142,7 @@ class V3Options { bool m_bboxUnsup; // main switch: --bbox-unsup bool m_cdc; // main switch: --cdc bool m_cmake; // main switch: --make cmake + bool m_context; // main switch: --Wcontext bool m_coverageLine; // main switch: --coverage-block bool m_coverageToggle;// main switch: --coverage-toggle bool m_coverageUnderscore;// main switch: --coverage-underscore @@ -320,6 +321,7 @@ class V3Options { bool bboxUnsup() const { return m_bboxUnsup; } bool cdc() const { return m_cdc; } bool cmake() const { return m_cmake; } + bool context() const { return m_context; } bool coverage() const { return m_coverageLine || m_coverageToggle || m_coverageUser; } bool coverageLine() const { return m_coverageLine; } bool coverageToggle() const { return m_coverageToggle; } diff --git a/src/verilog.y b/src/verilog.y index d3074fae5..e81a80950 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -227,7 +227,7 @@ static void ERRSVKWD(FileLine* fileline, const string& tokname) { static void UNSUPREAL(FileLine* fileline) { fileline->v3warn(SHORTREAL, "Unsupported: shortreal being promoted to real (suggest use real instead)"); } - + //====================================================================== class AstSenTree; diff --git a/test_regress/t/t_flag_context_bad.out b/test_regress/t/t_flag_context_bad.out new file mode 100644 index 000000000..e1f8112fa --- /dev/null +++ b/test_regress/t/t_flag_context_bad.out @@ -0,0 +1,6 @@ +%Warning-WIDTH: t/t_flag_context_bad.v:8: Operator ASSIGNW expects 3 bits on the Assign RHS, but Assign RHS's CONST '5'h1f' generates 5 bits. + : ... In instance t + ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message. +%Warning-UNUSED: t/t_flag_context_bad.v:8: Signal is not used: 'foo' + : ... In instance t +%Error: Exiting due to diff --git a/test_regress/t/t_flag_context_bad.pl b/test_regress/t/t_flag_context_bad.pl new file mode 100755 index 000000000..0b9220293 --- /dev/null +++ b/test_regress/t/t_flag_context_bad.pl @@ -0,0 +1,19 @@ +#!/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(vlt => 1); + +lint( + verilator_flags2 => ["-Wall -Wno-DECLFILENAME -Wno-context"], + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_flag_context_bad.v b/test_regress/t/t_flag_context_bad.v new file mode 100644 index 000000000..741efcfec --- /dev/null +++ b/test_regress/t/t_flag_context_bad.v @@ -0,0 +1,10 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2019 by Wilson Snyder. + +module t (/*AUTOARG*/); + + wire [2:0] foo = 5'b11111; + +endmodule