Skip to content

Commit

Permalink
Merge pull request #3988 from alainmarcel/alainmarcel-patch-1
Browse files Browse the repository at this point in the history
Error out on unknown parameter override
  • Loading branch information
alaindargelas authored Sep 24, 2024
2 parents fd8dcc0 + 3f61df4 commit 4d8ef9e
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 305 deletions.
3 changes: 2 additions & 1 deletion include/Surelog/ErrorReporting/ErrorDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class ErrorDefinition {
ELAB_USE_INTERFACE_AS_SIGNAL_TYPE = 538,
ELAB_UNKNOWN_STRUCT_MEMBER = 539,
ELAB_UNKNOWN_INTERFACE_MEMBER = 540,
ELAB_UNKNOWN_PARAMETER = 541,
ELAB_UNKNOWN_PARAMETER_COMMAND = 541,
ELAB_EXPRESSION_LOOP = 542,
ELAB_SKIPPING_BLACKBOX_MODULE = 543,
ELAB_SKIPPING_BLACKBOX_INSTANCE = 544,
Expand All @@ -248,6 +248,7 @@ class ErrorDefinition {
ELAB_SYSTEM_INFO = 549,
ELAB_UNKNOWN_PORT = 550,
ELAB_TOP_PARAMETER_NO_DEFAULT = 551,
ELAB_UNKNOWN_PARAMETER_OVERRIDE = 552,
LIB_FILE_MAPS_TO_MULTIPLE_LIBS = 600,
UHDM_UNSUPPORTED_EXPR = 700,
UHDM_UNSUPPORTED_STMT = 701,
Expand Down
14 changes: 13 additions & 1 deletion src/DesignCompile/DesignElaboration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,18 @@ std::vector<std::string_view> DesignElaboration::collectParams_(
// Named param
const std::string_view name = parentFile->SymName(child);
overridenParams.insert(name);
if (module) {
Parameter* p = module->getParameter(name);
if (p == nullptr) {
Location loc(parentFile->getFileId(paramAssign),
parentFile->Line(paramAssign),
parentFile->Column(paramAssign),
st->registerSymbol(name));
Error err(ErrorDefinition::ELAB_UNKNOWN_PARAMETER_OVERRIDE, loc);
errors->addError(err);
continue;
}
}
NodeId expr = parentFile->Sibling(child);
if (!expr) {
Location loc(
Expand Down Expand Up @@ -2523,7 +2535,7 @@ void DesignElaboration::checkElaboration_() {
Location loc(
m_compileDesign->getCompiler()->getSymbolTable()->registerSymbol(
name));
Error err(ErrorDefinition::ELAB_UNKNOWN_PARAMETER, loc);
Error err(ErrorDefinition::ELAB_UNKNOWN_PARAMETER_COMMAND, loc);
m_compileDesign->getCompiler()->getErrorContainer()->addError(err);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/ErrorReporting/ErrorDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ bool ErrorDefinition::init() {
rec(ELAB_UNKNOWN_INTERFACE_MEMBER, ERROR, ELAB,
"Unknown interface member \"%s\"",
"%exloc interface definition for \"%exobj\"");
rec(ELAB_UNKNOWN_PARAMETER, ERROR, ELAB,
rec(ELAB_UNKNOWN_PARAMETER_OVERRIDE, ERROR, ELAB,
"Unknown parameter override \"%s\"");
rec(ELAB_UNKNOWN_PARAMETER_COMMAND, ERROR, ELAB,
"Unknown parameter in command line override \"%s\"");
rec(ELAB_EXPRESSION_LOOP, ERROR, ELAB, "Expression loop in instance \"%s\"");
rec(ELAB_SKIPPING_BLACKBOX_MODULE, INFO, ELAB,
Expand Down
Loading

0 comments on commit 4d8ef9e

Please sign in to comment.