mirror of
https://github.com/verilator/verilator.git
synced 2025-01-19 12:54:02 +00:00
With --Wall, add INCABSPATH warning on `include with absolute paths.
This commit is contained in:
parent
285277a50b
commit
fedf347b1a
4
Changes
4
Changes
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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); }
|
||||
|
@ -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: ");
|
||||
}
|
||||
|
||||
|
19
test_regress/t/t_lint_incabspath.pl
Executable file
19
test_regress/t/t_lint_incabspath.pl
Executable 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;
|
||||
|
9
test_regress/t/t_lint_incabspath.v
Normal file
9
test_regress/t/t_lint_incabspath.v
Normal 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
|
26
test_regress/t/t_lint_incabspath_bad.pl
Executable file
26
test_regress/t/t_lint_incabspath_bad.pl
Executable 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;
|
||||
|
Loading…
Reference in New Issue
Block a user