From b378dccbe9a6d8c5040aea9b7d94c248ee3746a0 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 8 Mar 2013 09:59:25 -0800 Subject: [PATCH] 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. --- parse.y | 2 +- pform.cc | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/parse.y b/parse.y index c75cd90bb..4fa9aac55 100644 --- a/parse.y +++ b/parse.y @@ -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 diff --git a/pform.cc b/pform.cc index bdb55e3f3..c559cd44b 100644 --- a/pform.cc +++ b/pform.cc @@ -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 (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 (scope))) pform_cur_module.front()->param_names.push_back(name); }