diff --git a/elaborate.cc b/elaborate.cc index be406747e..783840a81 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -1307,6 +1307,10 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const perm_string pname = peek_tail_name(mport[0]->path()); NetNet*tmp = instance[0]->find_signal(pname); + + // Handle the error case where there is no internal + // signal connected to the port. + if (!tmp) continue; assert(tmp); if (tmp->port_type() == NetNet::PINPUT) { diff --git a/pform.cc b/pform.cc index b8a408b86..7b899b688 100644 --- a/pform.cc +++ b/pform.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -344,7 +344,16 @@ PTask* pform_push_task_scope(const struct vlltype&loc, char*name, bool is_auto) FILE_NAME(task, loc); PScopeExtra*scopex = find_nearest_scopex(lexical_scope); - assert(scopex); + if ((scopex == 0) && (generation_flag < GN_VER2005_SV)) { + cerr << task->get_fileline() << ": error: task declarations " + "must be contained within a module." << endl; + error_count += 1; + } + if ((scopex == 0) && (generation_flag >= GN_VER2005_SV)) { + cerr << task->get_fileline() << ": sorry: task declarations " + "in the compilation unit scope are not yet supported." << endl; + error_count += 1; + } if (pform_cur_generate) { // Check if the task is already in the dictionary. @@ -357,7 +366,7 @@ PTask* pform_push_task_scope(const struct vlltype&loc, char*name, bool is_auto) error_count += 1; } pform_cur_generate->tasks[task->pscope_name()] = task; - } else { + } else if (scopex) { // Check if the task is already in the dictionary. if (scopex->tasks.find(task->pscope_name()) != scopex->tasks.end()) { cerr << task->get_fileline() << ": error: duplicate " @@ -381,13 +390,17 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, const char*name, PFunction*func = new PFunction(func_name, lexical_scope, is_auto); FILE_NAME(func, loc); - LexicalScope*scope = lexical_scope; - PScopeExtra*scopex = dynamic_cast (scope); - while (scope && !scopex) { - scope = scope->parent_scope(); - scopex = dynamic_cast (scope); + PScopeExtra*scopex = find_nearest_scopex(lexical_scope); + if ((scopex == 0) && (generation_flag < GN_VER2005_SV)) { + cerr << func->get_fileline() << ": error: function declarations " + "must be contained within a module." << endl; + error_count += 1; + } + if ((scopex == 0) && (generation_flag >= GN_VER2005_SV)) { + cerr << func->get_fileline() << ": sorry: function declarations " + "in the compilation unit scope are not yet supported." << endl; + error_count += 1; } - assert(scopex); if (pform_cur_generate) { // Check if the function is already in the dictionary. @@ -400,7 +413,7 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, const char*name, error_count += 1; } pform_cur_generate->funcs[func->pscope_name()] = func; - } else { + } else if (scopex != 0) { // Check if the function is already in the dictionary. if (scopex->funcs.find(func->pscope_name()) != scopex->funcs.end()) { cerr << func->get_fileline() << ": error: duplicate " diff --git a/tgt-vlog95/Makefile.in b/tgt-vlog95/Makefile.in index 19428f2e9..69a57b618 100644 --- a/tgt-vlog95/Makefile.in +++ b/tgt-vlog95/Makefile.in @@ -56,7 +56,8 @@ distclean: clean rm -f Makefile config.log cppcheck: $(O:.o=.c) - cppcheck --enable=all -f $(INCLUDE_PATH) $^ + cppcheck --enable=all -f --suppressions-list=$(srcdir)/cppcheck.sup \ + --relative-paths=$(srcdir) $(INCLUDE_PATH) $^ Makefile: $(srcdir)/Makefile.in ../config.status cd ..; ./config.status --file=tgt-vlog95/$@ diff --git a/tgt-vlog95/cppcheck.sup b/tgt-vlog95/cppcheck.sup new file mode 100644 index 000000000..f1a757bf9 --- /dev/null +++ b/tgt-vlog95/cppcheck.sup @@ -0,0 +1,8 @@ +// These are the global access functions called from the compiler so they +// are not used here. + +// target_design() +unusedFunction:vlog95.c:59 + +// target_query() +unusedFunction:vlog95.c:226 diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index aaf8f0203..0c29fa4b6 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1713,8 +1713,10 @@ template bool vector4_to_value(const vvp_vector4_t&vec, T&val) break; case BIT4_1: // On overflow, return the maximum value of type T - if (msk == 0) return ~msk; - res |= msk; + if (msk == 0) + res = ~msk; + else + res |= msk; break; default: return false;