Add IMPORTSTAR warning on import::* inside scope.

This commit is contained in:
Wilson Snyder
2018-11-28 18:25:34 -05:00
parent 15af706286
commit 61e4b0a472
7 changed files with 67 additions and 10 deletions
+5 -1
View File
@@ -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());