From 32a2e7aa39f0e098776a84db8fa3f1a7c250158f Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 2 Mar 2008 21:04:04 -0800 Subject: [PATCH] Fix lexical scopes within case-generate alternatives. Case-generate alternatives create sub-scopes that need to be scanned by the scope scanner in order to get function definitions etc. that are defined lexically within generated scopes. --- emit.cc | 4 +++- netlist.h | 6 +++--- parse.y | 1 + tgt-stub/stub.c | 7 ++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/emit.cc b/emit.cc index 49b97265c..f94d0403b 100644 --- a/emit.cc +++ b/emit.cc @@ -378,7 +378,9 @@ bool NetScope::emit_defs(struct target_t*tgt) const case TASK: tgt->task_def(this); break; - default: /* BEGIN_END and FORK_JOIN, do nothing */ + default: /* BEGIN_END and FORK_JOIN, GENERATE... */ + for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) + flag &= cur->emit_defs(tgt); break; } diff --git a/netlist.h b/netlist.h index 066ba09c2..533e6bdc0 100644 --- a/netlist.h +++ b/netlist.h @@ -3332,9 +3332,9 @@ class NetScope : public Attrib { void default_nettype(NetNet::Type); NetNet::Type default_nettype() const; - /* The name of the scope is the fully qualified hierarchical - name, whereas the basename is just my name within my parent - scope. */ + /* The fullname of the scope is the hierarchical name + component (which includes the name and array index) whereas + the basename is just my name. */ perm_string basename() const; const hname_t& fullname() const { return name_; } diff --git a/parse.y b/parse.y index 5ed7af2d0..c969b79c2 100644 --- a/parse.y +++ b/parse.y @@ -1880,6 +1880,7 @@ module_item | K_function function_range_or_type_opt IDENTIFIER ';' { assert(current_function == 0); current_function = pform_push_function_scope($3); + FILE_NAME(current_function, @1); } function_item_list statement K_endfunction diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 300aefd30..eac616ca9 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -1454,7 +1454,12 @@ static int show_scope(ivl_scope_t net, void*x) case IVL_SCT_FUNCTION: case IVL_SCT_TASK: fprintf(out, " scope function/task definition\n"); - show_statement(ivl_scope_def(net), 6); + if (ivl_scope_def(net) == 0) { + fprintf(out, " ERROR: scope missing required task definition\n"); + stub_errors += 1; + } else { + show_statement(ivl_scope_def(net), 6); + } break; default: