Internals: Pass fileline directly. No functional change intended.

This commit is contained in:
Wilson Snyder 2020-06-07 10:51:54 -04:00
parent 53d8ccd149
commit 820a4dbbdd
5 changed files with 49 additions and 14 deletions

View File

@ -89,7 +89,7 @@ void V3ParseImp::timescalePreproc(FileLine* fl, const char* textp) {
VTimescale prec; VTimescale prec;
VTimescale::parseSlashed(fl, textp, unit /*ref*/, prec /*ref*/); VTimescale::parseSlashed(fl, textp, unit /*ref*/, prec /*ref*/);
m_timeLastUnit = v3Global.opt.timeComputeUnit(unit); m_timeLastUnit = v3Global.opt.timeComputeUnit(unit);
v3Global.rootp()->timeprecisionMerge(fileline(), prec); v3Global.rootp()->timeprecisionMerge(fl, prec);
} }
void V3ParseImp::timescaleMod(FileLine* fl, AstNodeModule* modp, bool unitSet, double unitVal, void V3ParseImp::timescaleMod(FileLine* fl, AstNodeModule* modp, bool unitSet, double unitVal,
bool precSet, double precVal) { bool precSet, double precVal) {
@ -118,7 +118,7 @@ void V3ParseImp::timescaleMod(FileLine* fl, AstNodeModule* modp, bool unitSet, d
fl->v3error("timeunit/timeprecision not under a module"); fl->v3error("timeunit/timeprecision not under a module");
} }
} }
v3Global.rootp()->timeprecisionMerge(fileline(), prec); v3Global.rootp()->timeprecisionMerge(fl, prec);
} }
void V3ParseImp::verilatorCmtLintSave() { m_lintState.push_back(*parsep()->fileline()); } void V3ParseImp::verilatorCmtLintSave() { m_lintState.push_back(*parsep()->fileline()); }
@ -134,15 +134,16 @@ void V3ParseImp::verilatorCmtLintRestore(FileLine* fl) {
void V3ParseImp::verilatorCmtLint(FileLine* fl, const char* textp, bool warnOff) { void V3ParseImp::verilatorCmtLint(FileLine* fl, const char* textp, bool warnOff) {
const char* sp = textp; const char* sp = textp;
while (*sp && !isspace(*sp)) sp++; while (*sp && !isspace(*sp)) ++sp;
while (*sp && isspace(*sp)) sp++; while (*sp && isspace(*sp)) ++sp;
while (*sp && !isspace(*sp)) sp++; while (*sp && !isspace(*sp)) ++sp;
while (*sp && isspace(*sp)) sp++; while (*sp && isspace(*sp)) ++sp;
string msg = sp; string msg = sp;
string::size_type pos; string::size_type pos;
if ((pos = msg.find('*')) != string::npos) msg.erase(pos); if ((pos = msg.find('*')) != string::npos) msg.erase(pos);
// Use parsep()->fileline() as want to affect later FileLine's warnings
if (!(parsep()->fileline()->warnOff(msg, warnOff))) { if (!(parsep()->fileline()->warnOff(msg, warnOff))) {
if (!parsep()->optFuture(msg)) { if (!v3Global.opt.isFuture(msg)) {
fl->v3error("Unknown verilator lint message code: '" << msg << "', in '" << textp fl->v3error("Unknown verilator lint message code: '" << msg << "', in '" << textp
<< "'"); << "'");
} }
@ -157,10 +158,12 @@ void V3ParseImp::verilatorCmtBad(FileLine* fl, const char* textp) {
while (isspace(cmtparse[0])) cmtparse.replace(0, 1, ""); while (isspace(cmtparse[0])) cmtparse.replace(0, 1, "");
string cmtname; string cmtname;
for (int i = 0; isalnum(cmtparse[i]); i++) { cmtname += cmtparse[i]; } for (int i = 0; isalnum(cmtparse[i]); i++) { cmtname += cmtparse[i]; }
if (!parsep()->optFuture(cmtname)) fl->v3error("Unknown verilator comment: '" << textp << "'"); if (!v3Global.opt.isFuture(cmtname)) {
fl->v3error("Unknown verilator comment: '" << textp << "'");
}
} }
void V3ParseImp::errorPreprocDirective(const char* textp) { void V3ParseImp::errorPreprocDirective(FileLine* fl, const char* textp) {
// Find all `preprocessor spelling candidates // Find all `preprocessor spelling candidates
// Can't make this static as might get more defines later when read cells // Can't make this static as might get more defines later when read cells
VSpellCheck speller; VSpellCheck speller;
@ -171,9 +174,9 @@ void V3ParseImp::errorPreprocDirective(const char* textp) {
} }
V3PreShell::candidateDefines(&speller); V3PreShell::candidateDefines(&speller);
string suggest = speller.bestCandidateMsg(textp); string suggest = speller.bestCandidateMsg(textp);
fileline()->v3error("Define or directive not defined: '" fl->v3error("Define or directive not defined: '"
<< textp << "'\n" << textp << "'\n"
<< (suggest.empty() ? "" : fileline()->warnMore() + suggest)); << (suggest.empty() ? "" : fl->warnMore() + suggest));
} }
void V3ParseImp::tag(const char* text) { void V3ParseImp::tag(const char* text) {

View File

@ -152,7 +152,7 @@ public:
void verilatorCmtLintSave(); void verilatorCmtLintSave();
void verilatorCmtLintRestore(FileLine* fl); void verilatorCmtLintRestore(FileLine* fl);
void verilatorCmtBad(FileLine* fl, const char* textp); void verilatorCmtBad(FileLine* fl, const char* textp);
void errorPreprocDirective(const char* textp); static void errorPreprocDirective(FileLine* fl, const char* textp);
void tag(const char* text); void tag(const char* text);
void tagNodep(AstNode* nodep) { m_tagNodep = nodep; } void tagNodep(AstNode* nodep) { m_tagNodep = nodep; }
AstNode* tagNodep() const { return m_tagNodep; } AstNode* tagNodep() const { return m_tagNodep; }

View File

@ -1021,7 +1021,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
/* Default rules - leave last */ /* Default rules - leave last */
<V95,V01,V05,VA5,S05,S09,S12,S17,SAX,VLT>{ <V95,V01,V05,VA5,S05,S09,S12,S17,SAX,VLT>{
"`"[a-zA-Z_0-9]+ { FL_FWD; PARSEP->errorPreprocDirective(yytext); FL_BRK; } "`"[a-zA-Z_0-9]+ { FL; PARSEP->errorPreprocDirective(yylval.fl, yytext); FL_BRK; }
"//"[^\n]* { FL_FWD; FL_BRK; } /* throw away single line comments */ "//"[^\n]* { FL_FWD; FL_BRK; } /* throw away single line comments */
. { FL; return yytext[0]; } /* return single char ops. */ . { FL; return yytext[0]; } /* return single char ops. */
} }

View File

@ -0,0 +1,10 @@
%Error: t/t_flag_future.v:8:7: Unknown verilator lint message code: 'FUTURE1', in '/*verilator lint_off FUTURE1*/'
8 | /*verilator lint_off FUTURE1*/
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%Error: t/t_flag_future.v:11:7: Unknown verilator comment: '/*verilator FUTURE2*/'
11 | /*verilator FUTURE2*/
| ^~~~~~~~~~~~~~~~~~~~~
%Error: t/t_flag_future.v:12:7: Unknown verilator comment: '/*verilator FUTURE2 blah blah*/'
12 | /*verilator FUTURE2 blah blah*/
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%Error: Exiting due to

View File

@ -0,0 +1,22 @@
#!/usr/bin/env 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.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
top_filename("t/t_flag_future.v");
lint(
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;