Fix lint_off EOFNEWLINE in .vlt files (#3796).

This commit is contained in:
Wilson Snyder 2022-12-01 18:27:36 -05:00
parent 889a1211f1
commit e465a30eee
6 changed files with 50 additions and 2 deletions

View File

@ -30,6 +30,7 @@ Verilator 5.003 devel
* Fix wait 0.
* Fix comparing ranged slices of unpacked arrays.
* Fix empty string literals converting to string types (#3774). [miree]
* Fix lint_off EOFNEWLINE in .vlt files (#3796). [Andrew Nolte]
Verilator 5.002 2022-10-29

View File

@ -319,7 +319,7 @@ public:
const int curlineno = filelinep->lastLineno();
for (; m_lastIgnore.it != m_ignLines.end(); ++m_lastIgnore.it) {
if (m_lastIgnore.it->m_lineno > curlineno) break;
// UINFO(9, " Hit " << *m_lastIt << endl);
// UINFO(9, " Hit " << *m_lastIgnore.it << endl);
filelinep->warnOn(m_lastIgnore.it->m_code, m_lastIgnore.it->m_on);
}
if (false && debug() >= 9) {

View File

@ -19,6 +19,7 @@
#include "V3PreProc.h"
#include "V3Config.h"
#include "V3Error.h"
#include "V3File.h"
#include "V3Global.h"
@ -843,6 +844,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam
FileLine* const fl = new FileLine{flsp};
fl->contentLineno(eof_lineno);
fl->column(eof_newline + 1, eof_newline + 1);
V3Config::applyIgnores(fl); // As preprocessor hasn't otherwise applied yet
fl->v3warn(EOFNEWLINE, "Missing newline at end of file (POSIX 3.206).\n"
<< fl->warnMore() << "... Suggest add newline.");
}

View File

@ -0,0 +1,36 @@
#!/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
use IO::File;
use strict;
use vars qw($Self);
scenarios(vlt => 1);
sub gen {
my $filename = shift;
my $fh = IO::File->new(">$filename");
$fh->print("// Generated by t_lint_eofline_bad.pl\n");
$fh->print("module t;\n");
$fh->print("// No newline below:\n");
$fh->print("endmodule"); # Intentionally no newline
}
top_filename("$Self->{obj_dir}/t_lint_eofline_bad.v");
gen($Self->{top_filename});
lint(
verilator_flags2 => ["--lint-only -Wall -Wno-DECLFILENAME t/t_lint_eofline_vlt.vlt"],
);
ok(1);
1;

View File

@ -0,0 +1,9 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2010 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
`verilator_config
lint_off -rule EOFNEWLINE --file "*.v"

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1);
lint(
verilator_flags2 => ["--lint-only t/t_vlt_warn.vlt -Wall"],
verilator_flags2 => ["--lint-only -Wall t/t_vlt_warn.vlt"],
);
ok(1);