Update parameter add code to correctly handle a non-Module scope

A package can have parameters, but it does not have specparams or
keep the order the parameters are defined. This patch skips these
items if the scope is not a Module.
This commit is contained in:
Cary R 2013-03-08 09:59:25 -08:00
parent 1f9489a65d
commit b378dccbe9
2 changed files with 9 additions and 4 deletions

View File

@ -2963,7 +2963,7 @@ expr_primary
}
| IDENTIFIER K_SCOPE_RES IDENTIFIER
{ $$ = pform_package_ident(@3, $1, $3); }
{ $$ = pform_package_ident(@2, $1, $3); }
/* An identifier followed by an expression list in parentheses is a
function call. If a system identifier, then a system function

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -2507,8 +2507,11 @@ void pform_set_parameter(const struct vlltype&loc,
<< "' have the same name '" << name << "'." << endl;
error_count += 1;
}
// Only a Module scope has specparams.
if ((scope == pform_cur_module.front()) &&
(pform_cur_module.front()->specparams.find(name) != pform_cur_module.front()->specparams.end())) {
(dynamic_cast<Module*> (scope)) &&
(pform_cur_module.front()->specparams.find(name) !=
pform_cur_module.front()->specparams.end())) {
LineInfo tloc;
FILE_NAME(&tloc, loc);
cerr << tloc.get_fileline() << ": error: specparam and "
@ -2538,7 +2541,9 @@ void pform_set_parameter(const struct vlltype&loc,
parm.signed_flag = signed_flag;
parm.range = value_range;
if (scope == pform_cur_module.front())
// Only a Module keeps the position of the parameter.
if ((scope == pform_cur_module.front()) &&
(dynamic_cast<Module*> (scope)))
pform_cur_module.front()->param_names.push_back(name);
}