Add --Wno-fatal to turn off abort on warnings.

This commit is contained in:
Wilson Snyder 2011-03-22 18:09:39 -04:00
parent df0aa483ce
commit fb70a1f4ab
8 changed files with 56 additions and 1 deletions

View File

@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks!
*** Add --trace-max-width and --trace-max-array, bug 319. [Alex Solomatnikov] *** Add --trace-max-width and --trace-max-array, bug 319. [Alex Solomatnikov]
*** Add --Wno-fatal to turn off abort on warnings. [by Stefan Wallentowitz]
**** Support ${...} and $(...) env vars in .vc files. [by Stefan Wallentowitz] **** Support ${...} and $(...) env vars in .vc files. [by Stefan Wallentowitz]
**** Support $bits(data_type), bug327. [Alex Solomatnikov] **** Support $bits(data_type), bug327. [Alex Solomatnikov]

View File

@ -306,6 +306,7 @@ descriptions in the next sections for more information.
-Wno-<message> Disable warning -Wno-<message> Disable warning
-Wno-lint Disable all lint warnings -Wno-lint Disable all lint warnings
-Wno-style Disable all style warnings -Wno-style Disable all style warnings
-Wno-fatal Disable fatal exit on warnings
-x-assign <mode> Initially assign Xs to this value -x-assign <mode> Initially assign Xs to this value
-y <dir> Directory to search for modules -y <dir> Directory to search for modules
@ -912,6 +913,14 @@ already disabled). This is equivalent to "-Wno-DECLFILENAME -Wno-DEFPARAM
-Wno-INCABSPATH -Wno-SYNCASYNCNET -Wno-UNDRIVEN -Wno-UNUSED -Wno-INCABSPATH -Wno-SYNCASYNCNET -Wno-UNDRIVEN -Wno-UNUSED
-Wno-VARHIDDEN". -Wno-VARHIDDEN".
=item -Wno-fatal
When warnings are detected, print them, but do not exit the simulator.
Having warning messages in builds is sloppy. It is strongly recommended
you cleanup your code, use inline lint_off, or use -Wno-... flags rather
than using this option.
=item -Wwarn-I<message> =item -Wwarn-I<message>
Enables the specified warning message. Enables the specified warning message.

View File

@ -309,7 +309,7 @@ void V3Error::abortIfErrors() {
} }
void V3Error::abortIfWarnings() { void V3Error::abortIfWarnings() {
if (errorOrWarnCount()) { if (v3Global.opt.warnFatal() ? errorOrWarnCount() : errorCount()) {
v3fatal ("Exiting due to "<<dec<<errorOrWarnCount()<<" warning(s)\n"); v3fatal ("Exiting due to "<<dec<<errorOrWarnCount()<<" warning(s)\n");
} }
} }

View File

@ -831,6 +831,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if (!strcmp (sw, "-Wno-style")) { else if (!strcmp (sw, "-Wno-style")) {
FileLine::globalWarnStyleOff(true); FileLine::globalWarnStyleOff(true);
} }
else if (!strcmp (sw, "-Wno-fatal")) {
m_warnFatal = false;
}
else { else {
string msg = sw+strlen("-Wno-"); string msg = sw+strlen("-Wno-");
if (!(FileLine::globalWarnOff(msg, true))) { if (!(FileLine::globalWarnOff(msg, true))) {
@ -1080,6 +1083,7 @@ V3Options::V3Options() {
m_makeDepend = true; m_makeDepend = true;
m_makePhony = false; m_makePhony = false;
m_outFormatOk = false; m_outFormatOk = false;
m_warnFatal = true;
m_pinsBv = 65; m_pinsBv = 65;
m_profileCFuncs = false; m_profileCFuncs = false;
m_preprocOnly = false; m_preprocOnly = false;

View File

@ -113,6 +113,7 @@ class V3Options {
bool m_l2Name; // main switch: --l2name bool m_l2Name; // main switch: --l2name
bool m_lintOnly; // main switch: --lint-only bool m_lintOnly; // main switch: --lint-only
bool m_outFormatOk; // main switch: --cc, --sc or --sp was specified bool m_outFormatOk; // main switch: --cc, --sc or --sp was specified
bool m_warnFatal; // main switch: --warnFatal
bool m_pinsUint8; // main switch: --pins-uint8 bool m_pinsUint8; // main switch: --pins-uint8
bool m_profileCFuncs;// main switch: --profile-cfuncs bool m_profileCFuncs;// main switch: --profile-cfuncs
bool m_psl; // main switch: --psl bool m_psl; // main switch: --psl
@ -240,6 +241,7 @@ class V3Options {
bool traceUnderscore() const { return m_traceUnderscore; } bool traceUnderscore() const { return m_traceUnderscore; }
bool outFormatOk() const { return m_outFormatOk; } bool outFormatOk() const { return m_outFormatOk; }
bool keepTempFiles() const { return (V3Error::debugDefault()!=0); } bool keepTempFiles() const { return (V3Error::debugDefault()!=0); }
bool warnFatal() const { return m_warnFatal; }
bool pinsUint8() const { return m_pinsUint8; } bool pinsUint8() const { return m_pinsUint8; }
bool profileCFuncs() const { return m_profileCFuncs; } bool profileCFuncs() const { return m_profileCFuncs; }
bool psl() const { return m_psl; } bool psl() const { return m_psl; }

View File

@ -630,6 +630,8 @@ int main(int argc, char** argv, char** env) {
V3File::writeTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__verFiles.dat", argString); V3File::writeTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__verFiles.dat", argString);
} }
// Final writing shouldn't throw warnings, but...
V3Error::abortIfWarnings();
#ifdef VL_LEAK_CHECKS #ifdef VL_LEAK_CHECKS
// Cleanup memory for valgrind leak analysis // Cleanup memory for valgrind leak analysis
v3Global.clear(); v3Global.clear();

25
test_regress/t/t_flag_wfatal.pl Executable file
View File

@ -0,0 +1,25 @@
#!/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.
top_filename("t/t_flag_wfatal.v");
compile (
v_flags2 => ["--lint-only -Wno-fatal"],
fails=>0,
verilator_make_gcc => 0,
make_top_shell => 0,
make_main => 0,
expect=>
q{%Warning-WIDTH: t/t_flag_wfatal.v:\d+: Operator ASSIGNW expects 4 bits on the Assign RHS, but Assign RHS.s CONST '6'h2e' generates 6 bits.
%Warning-WIDTH: Use .* and lint_on around source to disable this message.
},
) if $Self->{v3};
ok(1);
1;

View File

@ -0,0 +1,11 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2005 by Wilson Snyder.
module t (/*AUTOARG*/);
// Width error below
wire [3:0] foo = 6'h2e;
endmodule