Add -Wno-context.

Signed-off-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
Wilson Snyder 2019-11-23 10:39:36 -05:00
parent df192f2b61
commit 3d6e8e9eb0
9 changed files with 56 additions and 6 deletions

View File

@ -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]

View File

@ -398,6 +398,7 @@ detailed descriptions in L</"VERILATION ARGUMENTS"> for more information.
-Werror-<message> Convert warnings to errors
-Wfuture-<message> Disable unknown message warnings
-Wno-<message> 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.

View File

@ -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();

View File

@ -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;

View File

@ -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; }

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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