Add --Wfuture-, for improving forward compatibility.
This commit is contained in:
parent
9e5fb5467f
commit
8a7864ebaa
2
Changes
2
Changes
|
|
@ -18,6 +18,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
|||
|
||||
*** Add $random.
|
||||
|
||||
*** Add --Wfuture-, for improving forward compatibility.
|
||||
|
||||
**** Fix verilator_includer not being installed properly. [Holger Waechtler]
|
||||
|
||||
**** Fix IMPURE errors due to X-assignment temporary variables. [Steve Tong]
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ descriptions in the next sections for more information.
|
|||
--underline-zero Zero signals with leading _'s
|
||||
-v <filename> Verilog library
|
||||
-Werror-<message> Convert warning to error
|
||||
-Wfuture-<message> Disable unknown message warnings
|
||||
-Wno-<message> Disable warning
|
||||
-x-assign <mode> Initially assign Xs to this value
|
||||
-y <dir> Directory to search for modules
|
||||
|
|
@ -556,6 +557,14 @@ Convert the specified warning message into a error message. This is
|
|||
generally to discourage users from violating important site-wide rules, for
|
||||
example C<-Werror-NOUNOPTFLAT>.
|
||||
|
||||
=item -Wfuture-I<message>
|
||||
|
||||
Suppress unknown Verilator comments or warning messages with the given
|
||||
message code. This is used to allow code written with pragmas for a later
|
||||
version of Verilator to run under a older version; add -Wfuture- arguments
|
||||
for each message code or comment that the new version supports which the
|
||||
older version does not support.
|
||||
|
||||
=item -Wno-I<message>
|
||||
|
||||
Disable the specified warning message.
|
||||
|
|
|
|||
|
|
@ -95,6 +95,15 @@ void V3Options::addCppFile(const string& filename) {
|
|||
m_cppFiles.insert(filename);
|
||||
}
|
||||
}
|
||||
void V3Options::addFuture(const string& flag) {
|
||||
if (m_futures.find(flag) == m_futures.end()) {
|
||||
m_futures.insert(flag);
|
||||
}
|
||||
}
|
||||
bool V3Options::isFuture(const string& flag) const {
|
||||
return m_futures.find(flag) != m_futures.end();
|
||||
}
|
||||
|
||||
void V3Options::addLibraryFile(const string& filename) {
|
||||
if (m_libraryFiles.find(filename) == m_libraryFiles.end()) {
|
||||
m_libraryFiles.insert(filename);
|
||||
|
|
@ -646,11 +655,18 @@ void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) {
|
|||
string msg = sw+strlen("-Werror-");
|
||||
V3ErrorCode code (msg.c_str());
|
||||
if (code == V3ErrorCode::ERROR) {
|
||||
fl->v3fatal("Unknown warning specified: "<<sw);
|
||||
if (!isFuture(msg)) {
|
||||
fl->v3fatal("Unknown warning specified: "<<sw);
|
||||
}
|
||||
} else {
|
||||
V3Error::pretendError(code, true);
|
||||
}
|
||||
}
|
||||
else if ( !strncmp (sw, "-Wfuture-",strlen("-Wfuture-")) ) {
|
||||
string msg = sw+strlen("-Wfuture-");
|
||||
// Note it may not be a future option, but one that is currently implemented.
|
||||
addFuture(msg);
|
||||
}
|
||||
else if ( !strcmp (sw, "-bin") && (i+1)<argc ) {
|
||||
shift; m_bin = argv[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class V3Options {
|
|||
V3OptionsImp* m_impp; // Slow hidden options
|
||||
|
||||
V3StringSet m_cppFiles; // argument: C++ files to link against
|
||||
V3StringSet m_futures; // argument: -Wfuture- list
|
||||
V3StringSet m_libraryFiles; // argument: Verilog -v files
|
||||
V3StringList m_vFiles; // argument: Verilog files to read
|
||||
|
||||
|
|
@ -151,9 +152,10 @@ class V3Options {
|
|||
private:
|
||||
// METHODS
|
||||
void addArg(const string& incdir);
|
||||
void addDefine(const string& defline);
|
||||
void addFuture(const string& flag);
|
||||
void addIncDir(const string& incdir);
|
||||
void addLibExt(const string& libext);
|
||||
void addDefine(const string& defline);
|
||||
void optimize(int level);
|
||||
void coverage(bool flag) { m_coverageLine = m_coverageUser = flag; }
|
||||
bool onoff(const char* sw, const char* arg, bool& flag);
|
||||
|
|
@ -219,11 +221,14 @@ class V3Options {
|
|||
string modPrefix() const { return m_modPrefix; }
|
||||
string topModule() const { return m_topModule; }
|
||||
string xAssign() const { return m_xAssign; }
|
||||
|
||||
const V3StringSet& cppFiles() const { return m_cppFiles; }
|
||||
const V3StringSet& libraryFiles() const { return m_libraryFiles; }
|
||||
const V3StringList& vFiles() const { return m_vFiles; }
|
||||
const V3LangCode& language() const { return m_language; }
|
||||
|
||||
bool isFuture(const string& flag) const;
|
||||
|
||||
// ACCESSORS (optimization options)
|
||||
bool oAcycSimp() const { return m_oAcycSimp; }
|
||||
bool oCase() const { return m_oCase; }
|
||||
|
|
|
|||
|
|
@ -181,6 +181,9 @@ void V3Read::lexFile(const string& modname) {
|
|||
bool V3Read::optPsl() {
|
||||
return v3Global.opt.psl();
|
||||
}
|
||||
bool V3Read::optFuture(const string& flag) {
|
||||
return v3Global.opt.isFuture(flag);
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// Lex internal functions
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ protected:
|
|||
friend class V3PreShellImp;
|
||||
int yylexThis();
|
||||
static bool optPsl();
|
||||
static bool optFuture(const string& flag);
|
||||
static void ppline (const char* text);
|
||||
static void incLineno() { s_readp->fileline()->incLineno(); }
|
||||
static void verilatorCmtLint(const char* text, bool on);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,9 @@ void V3Read::verilatorCmtLint(const char* textp, bool warnOff) {
|
|||
string::size_type pos;
|
||||
if ((pos=msg.find("*")) != string::npos) { msg.erase(pos); }
|
||||
if (!(V3Read::fileline()->warnOff(msg, warnOff))) {
|
||||
yyerrorf("Unknown verilator lint message code: %s, in %s",msg.c_str(), textp);
|
||||
if (!V3Read::optFuture(msg)) {
|
||||
yyerrorf("Unknown verilator lint message code: %s, in %s",msg.c_str(), textp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +73,20 @@ void V3Read::verilatorCmtLintRestore() {
|
|||
}
|
||||
|
||||
void V3Read::verilatorCmtBad(const char* textp) {
|
||||
yyerrorf("Unknown verilator comment: %s",textp);
|
||||
string cmtparse = textp;
|
||||
if (cmtparse.substr(0,strlen("/*verilator")) == "/*verilator") {
|
||||
cmtparse.replace(0,strlen("/*verilator"), "");
|
||||
}
|
||||
while (isspace(cmtparse[0])) {
|
||||
cmtparse.replace(0,1, "");
|
||||
}
|
||||
string cmtname;
|
||||
for (int i=0; isalnum(cmtparse[i]); i++) {
|
||||
cmtname += cmtparse[i];
|
||||
}
|
||||
if (!V3Read::optFuture(cmtname)) {
|
||||
yyerrorf("Unknown verilator comment: %s",textp);
|
||||
}
|
||||
}
|
||||
|
||||
// See V3Read.cpp
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("./driver.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2008 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# General Public License or the Perl Artistic License.
|
||||
|
||||
compile (
|
||||
verilator_flags2 => [qw(-Wfuture-FUTURE1 -Wfuture-FUTURE2)],
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
|
||||
module t;
|
||||
initial begin
|
||||
// verilator lint_off FUTURE1
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
// verilator FUTURE2
|
||||
// verilator FUTURE2 blah blah
|
||||
end
|
||||
endmodule
|
||||
Loading…
Reference in New Issue