With --Wall, add INCABSPATH warning on `include with absolute paths.

This commit is contained in:
Wilson Snyder 2010-12-25 15:50:07 -05:00
parent 285277a50b
commit fedf347b1a
7 changed files with 74 additions and 1 deletions

View File

@ -16,7 +16,9 @@ indicates the contributor was also the author of the fix; Thanks!
*** Suppress WIDTH warnings when adding/subtracting 1'b1.
*** With --Wall, add DEFPARAM warning to find deprecated defparam statements.
*** With --Wall, add DEFPARAM warning on deprecated defparam statements.
*** With --Wall, add INCABSPATH warning on `include with absolute paths.
**** When running with VERILATOR_ROOT, optionally find binaries under bin.

View File

@ -2437,6 +2437,17 @@ Verilator cannot schedule these variables correctly.
Ignoring this warning may make Verilator simulations differ from other
simulators.
=item INCABSPATH
Warns that an `include filename specifies an absolute path. This means the
code will not work on any other system with a different file system layout.
Instead of using absolute paths, relative paths (preferably without any
directory specified whatever) should be used, and +include used on the
command line to specify the top include source directory.
Disabled by default as this is a code style warning, it will simulate
correctly.
=item LITENDIAN
Warns that a vector is declared with little endian bit numbering

View File

@ -68,6 +68,7 @@ public:
IMPERFECTSCH, // Imperfect schedule (disabled by default)
IMPLICIT, // Implicit wire
IMPURE, // Impure function not being inlined
INCABSPATH, // Include has absolute path
LITENDIAN, // Little bit endian vector
MODDUP, // Duplicate module
MULTIDRIVEN, // Driven from multiple blocks
@ -103,6 +104,7 @@ public:
"CASEINCOMPLETE", "CASEOVERLAP", "CASEWITHX", "CASEX", "CDCRSTLOGIC", "CMPCONST",
"COMBDLY", "DEFPARAM",
"STMTDLY", "SYMRSVDWORD", "GENCLK", "IMPERFECTSCH", "IMPLICIT", "IMPURE",
"INCABSPATH",
"LITENDIAN", "MODDUP",
"MULTIDRIVEN", "REDEFMACRO",
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
@ -132,6 +134,7 @@ public:
|| m_e==WIDTH); }
// Warnings that are style only
bool styleError() const { return ( m_e==DEFPARAM
|| m_e==INCABSPATH
|| m_e==VARHIDDEN ); }
};
inline bool operator== (V3ErrorCode lhs, V3ErrorCode rhs) { return (lhs.m_e == rhs.m_e); }

View File

@ -90,6 +90,9 @@ protected:
}
void preprocInclude (FileLine* fl, const string& modname) {
if (modname[0]=='/' || modname[0]=='\\') {
fl->v3warn(INCABSPATH,"`include with absolute path should be relative, and use +include: "<<modname);
}
preprocOpen(fl, s_filterp, modname, "Cannot find include file: ");
}

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.
compile (
v_flags2 => ["--lint-only"],
verilator_make_gcc => 0,
make_top_shell => 0,
make_main => 0,
) if $Self->{v3};
ok(1);
1;

View File

@ -0,0 +1,9 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2010 by Wilson Snyder.
`include "/dev/null"
module t;
endmodule

View File

@ -0,0 +1,26 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.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
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
top_filename("t/t_lint_incabspath.v");
compile (
v_flags2 => ["--lint-only -Wall"],
fails=>1,
verilator_make_gcc => 0,
make_top_shell => 0,
make_main => 0,
expect=>
'%Warning-INCABSPATH: t/t_lint_incabspath.v:\d+: `include with absolute path should be relative, and use \+include: /dev/null
%Warning-INCABSPATH: Use .* to disable this message.
%Error: Exiting due to.*',
) if $Self->{v3};
ok(1);
1;