forked from github/verilator
Add IMPORTSTAR warning on import::* inside scope.
This commit is contained in:
parent
15af706286
commit
61e4b0a472
2
Changes
2
Changes
@ -12,6 +12,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
**** Add PROCASSWIRE error on behavioral assignments to wires, msg2737. [Neil Turton]
|
||||
|
||||
**** Add IMPORTSTAR warning on import::* inside $unit scope.
|
||||
|
||||
**** Fix --trace-lxt2 compile error on MinGW, msg2711. [HyungKi Jeong]
|
||||
|
||||
**** Fix hang on bad pattern keys, bug1364. [Matt Myers]
|
||||
|
@ -226,7 +226,7 @@ Verilator - Convert Verilog code to C++/SystemC
|
||||
verilator --version
|
||||
verilator --cc [options] [source_files.v]... [opt_c_files.cpp/c/cc/a/o/so]
|
||||
verilator --sc [options] [source_files.v]... [opt_c_files.cpp/c/cc/a/o/so]
|
||||
verilator --lint-only [source_files.v]...
|
||||
verilator --lint-only -Wall [source_files.v]...
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
@ -1414,8 +1414,8 @@ received from third parties.
|
||||
|
||||
Disable all code style related warning messages (note by default they are
|
||||
already disabled). This is equivalent to "-Wno-DECLFILENAME -Wno-DEFPARAM
|
||||
-Wno-INCABSPATH -Wno-PINCONNECTEMPTY -Wno-PINNOCONNECT -Wno-SYNCASYNCNET
|
||||
-Wno-UNDRIVEN -Wno-UNUSED -Wno-VARHIDDEN".
|
||||
-Wno-IMPORTSTAR -Wno-INCABSPATH -Wno-PINCONNECTEMPTY -Wno-PINNOCONNECT
|
||||
-Wno-SYNCASYNCNET -Wno-UNDRIVEN -Wno-UNUSED -Wno-VARHIDDEN".
|
||||
|
||||
=item -Wno-fatal
|
||||
|
||||
@ -3579,6 +3579,16 @@ Emacs, available from L<http://www.veripool.org/>
|
||||
Ignoring this warning will only suppress the lint check, it will simulate
|
||||
correctly.
|
||||
|
||||
=item IMPORTSTAR
|
||||
|
||||
Warns that an "import I<package>::*" statement is in $unit scope. This
|
||||
causes the imported symbols to polute the global namespace, defeating much
|
||||
of the purpose of having a package. Generally "import ::*" should only be
|
||||
used inside a lower scope such as a package or module.
|
||||
|
||||
Disabled by default as this is a code style warning; it will simulate
|
||||
correctly.
|
||||
|
||||
=item IMPURE
|
||||
|
||||
Warns that a task or function that has been marked with /*verilator
|
||||
|
@ -77,8 +77,9 @@ public:
|
||||
GENCLK, // Generated Clock
|
||||
IFDEPTH, // If statements too deep
|
||||
IMPERFECTSCH, // Imperfect schedule (disabled by default)
|
||||
IMPLICIT, // Implicit wire
|
||||
IMPURE, // Impure function not being inlined
|
||||
IMPLICIT, // Implicit wire
|
||||
IMPORTSTAR, // Import::* in $unit
|
||||
IMPURE, // Impure function not being inlined
|
||||
INCABSPATH, // Include has absolute path
|
||||
INFINITELOOP, // Infinite loop
|
||||
INITIALDLY, // Initial delayed statement
|
||||
@ -136,7 +137,7 @@ public:
|
||||
"CMPCONST", "COLONPLUS", "COMBDLY",
|
||||
"DEFPARAM", "DECLFILENAME",
|
||||
"ENDLABEL", "GENCLK",
|
||||
"IFDEPTH", "IMPERFECTSCH", "IMPLICIT", "IMPURE",
|
||||
"IFDEPTH", "IMPERFECTSCH", "IMPLICIT", "IMPORTSTAR", "IMPURE",
|
||||
"INCABSPATH", "INFINITELOOP", "INITIALDLY",
|
||||
"LITENDIAN", "MODDUP",
|
||||
"MULTIDRIVEN",
|
||||
@ -185,9 +186,10 @@ public:
|
||||
|| m_e==BLKSEQ
|
||||
|| m_e==DEFPARAM
|
||||
|| m_e==DECLFILENAME
|
||||
|| m_e==INCABSPATH
|
||||
|| m_e==PINCONNECTEMPTY
|
||||
|| m_e==PINNOCONNECT
|
||||
|| m_e==IMPORTSTAR
|
||||
|| m_e==INCABSPATH
|
||||
|| m_e==PINCONNECTEMPTY
|
||||
|| m_e==PINNOCONNECT
|
||||
|| m_e==SYNCASYNCNET
|
||||
|| m_e==UNDRIVEN
|
||||
|| m_e==UNUSED
|
||||
|
@ -1020,7 +1020,11 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||
virtual void visit(AstPackageImport* nodep) {
|
||||
UINFO(4," Link: "<<nodep<<endl);
|
||||
VSymEnt* srcp = m_statep->getNodeSym(nodep->packagep());
|
||||
if (nodep->name()!="*") {
|
||||
if (nodep->name()=="*") {
|
||||
if (m_curSymp == m_statep->dunitEntp()) {
|
||||
nodep->v3warn(IMPORTSTAR,"Import::* in $unit scope may pollute global namespace");
|
||||
}
|
||||
} else {
|
||||
VSymEnt* impp = srcp->findIdFlat(nodep->name());
|
||||
if (!impp) {
|
||||
nodep->v3error("Import object not found: "<<nodep->packagep()->prettyName()<<"::"<<nodep->prettyName());
|
||||
|
3
test_regress/t/t_lint_importstar_bad.out
Normal file
3
test_regress/t/t_lint_importstar_bad.out
Normal file
@ -0,0 +1,3 @@
|
||||
%Warning-IMPORTSTAR: t/t_lint_importstar_bad.v:10: Import::* in $unit scope may pollute global namespace
|
||||
%Warning-IMPORTSTAR: Use "/* verilator lint_off IMPORTSTAR */" and lint_on around source to disable this message.
|
||||
%Error: Exiting due to
|
23
test_regress/t/t_lint_importstar_bad.pl
Executable file
23
test_regress/t/t_lint_importstar_bad.pl
Executable file
@ -0,0 +1,23 @@
|
||||
#!/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.
|
||||
|
||||
scenarios(vlt_all => 1);
|
||||
|
||||
compile(
|
||||
v_flags2 => ["--lint-only -Wall -Wno-DECLFILENAME"],
|
||||
fails => 1,
|
||||
verilator_make_gcc => 0,
|
||||
make_top_shell => 0,
|
||||
make_main => 0,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
13
test_regress/t/t_lint_importstar_bad.v
Normal file
13
test_regress/t/t_lint_importstar_bad.v
Normal file
@ -0,0 +1,13 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2018 by Wilson Snyder.
|
||||
|
||||
package defs;
|
||||
int sig;
|
||||
endpackage
|
||||
|
||||
import defs::*;
|
||||
|
||||
module t;
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user