From c010145eaf69c9f72dce296728e7fb9e102c1b4c Mon Sep 17 00:00:00 2001 From: Larry Doolittle Date: Mon, 6 Oct 2008 09:53:39 -0700 Subject: [PATCH] Shadow reduction part 1 Start cleaning up shadowed variables, flagged by turning on -Wshadow. No intended change in functionality. Patch looks right, and is tested to compile and run on my machine. YMMV. --- netlist.cc | 82 +++++++++++++++++++++++------------------------ netlist.h | 2 +- vvp/array.cc | 8 ++--- vvp/compile.cc | 6 ++-- vvp/ufunc.cc | 4 +-- vvp/vthread.cc | 14 ++++---- vvp/vvp_island.cc | 9 +++--- vvp/vvp_net.cc | 12 +++---- vvp/vvp_net.h | 20 ++++++------ 9 files changed, 79 insertions(+), 78 deletions(-) diff --git a/netlist.cc b/netlist.cc index 20a9284ff..22de41afb 100644 --- a/netlist.cc +++ b/netlist.cc @@ -253,8 +253,8 @@ NetBranch::~NetBranch() { } -NetBus::NetBus(NetScope*s, unsigned pin_count) -: NetObj(s, perm_string::literal(""), pin_count) +NetBus::NetBus(NetScope*s, unsigned pin_count__) +: NetObj(s, perm_string::literal(""), pin_count__) { } @@ -782,9 +782,9 @@ const NetDelaySrc* NetNet::delay_path(unsigned idx) const } NetPartSelect::NetPartSelect(NetNet*sig, unsigned off, unsigned wid, - NetPartSelect::dir_t dir) + NetPartSelect::dir_t dir__) : NetNode(sig->scope(), sig->scope()->local_symbol(), 2), - off_(off), wid_(wid), dir_(dir) + off_(off), wid_(wid), dir_(dir__) { connect(pin(1), sig->pin(0)); set_line(*sig); @@ -880,22 +880,22 @@ const NetScope* NetProcTop::scope() const return scope_; } -NetCastInt::NetCastInt(NetScope*scope, perm_string n, unsigned width) -: NetNode(scope, n, 2), width_(width) +NetCastInt::NetCastInt(NetScope*scope__, perm_string n, unsigned width__) +: NetNode(scope__, n, 2), width_(width__) { pin(0).set_dir(Link::OUTPUT); pin(1).set_dir(Link::INPUT); } -NetCastReal::NetCastReal(NetScope*scope, perm_string n, bool signed_flag) -: NetNode(scope, n, 2), signed_flag_(signed_flag) +NetCastReal::NetCastReal(NetScope*scope__, perm_string n, bool signed_flag__) +: NetNode(scope__, n, 2), signed_flag_(signed_flag__) { pin(0).set_dir(Link::OUTPUT); pin(1).set_dir(Link::INPUT); } -NetConcat::NetConcat(NetScope*scope, perm_string n, unsigned wid, unsigned cnt) -: NetNode(scope, n, cnt+1), width_(wid) +NetConcat::NetConcat(NetScope*scope__, perm_string n, unsigned wid, unsigned cnt) +: NetNode(scope__, n, cnt+1), width_(wid) { pin(0).set_dir(Link::OUTPUT); for (unsigned idx = 1 ; idx < cnt+1 ; idx += 1) { @@ -912,9 +912,9 @@ unsigned NetConcat::width() const return width_; } -NetReplicate::NetReplicate(NetScope*scope, perm_string n, +NetReplicate::NetReplicate(NetScope*scope__, perm_string n, unsigned wid, unsigned rpt) -: NetNode(scope, n, 2), width_(wid), repeat_(rpt) +: NetNode(scope__, n, 2), width_(wid), repeat_(rpt) { pin(0).set_dir(Link::OUTPUT); pin(1).set_dir(Link::INPUT); @@ -948,8 +948,8 @@ unsigned NetReplicate::repeat() const * ... */ -NetFF::NetFF(NetScope*s, perm_string n, unsigned width) -: NetNode(s, n, 8), width_(width) +NetFF::NetFF(NetScope*s, perm_string n, unsigned width__) +: NetNode(s, n, 8), width_(width__) { pin_Clock().set_dir(Link::INPUT); pin_Enable().set_dir(Link::INPUT); @@ -1153,15 +1153,15 @@ const Link& NetAddSub::pin_Result() const return pin(3); } -NetArrayDq::NetArrayDq(NetScope*s, perm_string n, NetNet*mem, unsigned awid) +NetArrayDq::NetArrayDq(NetScope*s, perm_string n, NetNet*mem__, unsigned awid) : NetNode(s, n, 2), - mem_(mem), awidth_(awid) + mem_(mem__), awidth_(awid) { pin(0).set_dir(Link::OUTPUT); // Result pin(1).set_dir(Link::INPUT); // Address // Increment the expression reference count for the target // memory so that it is not deleted underneath me. - mem->incr_eref(); + mem_->incr_eref(); } NetArrayDq::~NetArrayDq() @@ -1210,11 +1210,11 @@ const Link& NetArrayDq::pin_Address() const * 2 -- Distance */ NetCLShift::NetCLShift(NetScope*s, perm_string n, - unsigned width, unsigned width_dist, - bool right_flag, bool signed_flag) + unsigned width__, unsigned width_dist__, + bool right_flag__, bool signed_flag__) : NetNode(s, n, 3), - width_(width), width_dist_(width_dist), - right_flag_(right_flag), signed_flag_(signed_flag) + width_(width__), width_dist_(width_dist__), + right_flag_(right_flag__), signed_flag_(signed_flag__) { pin(0).set_dir(Link::OUTPUT); // Result pin(1).set_dir(Link::INPUT); // Data @@ -1742,8 +1742,8 @@ unsigned NetBUFZ::width() const return width_; } -NetCaseCmp::NetCaseCmp(NetScope*s, perm_string n, unsigned wid, bool eeq) -: NetNode(s, n, 3), width_(wid), eeq_(eeq) +NetCaseCmp::NetCaseCmp(NetScope*s, perm_string n, unsigned wid, bool eeq__) +: NetNode(s, n, 3), width_(wid), eeq_(eeq__) { pin(0).set_dir(Link::OUTPUT); pin(1).set_dir(Link::INPUT); @@ -1974,8 +1974,8 @@ const NetScope* NetUTask::task() const return task_; } -NetAlloc::NetAlloc(NetScope*scope) -: scope_(scope) +NetAlloc::NetAlloc(NetScope*scope__) +: scope_(scope__) { } @@ -1993,8 +1993,8 @@ const NetScope* NetAlloc::scope() const return scope_; } -NetFree::NetFree(NetScope*scope) -: scope_(scope) +NetFree::NetFree(NetScope*scope__) +: scope_(scope__) { } @@ -2050,8 +2050,8 @@ bool NetExpr::has_width() const * be. However, if we don't, our default will be the width of the * largest operand. */ -NetEBBits::NetEBBits(char op, NetExpr*l, NetExpr*r) -: NetEBinary(op, l, r) +NetEBBits::NetEBBits(char op__, NetExpr*l, NetExpr*r) +: NetEBinary(op__, l, r) { if (r->expr_width() > l->expr_width()) expr_width(r->expr_width()); @@ -2070,8 +2070,8 @@ NetEBBits* NetEBBits::dup_expr() const return result; } -NetEBinary::NetEBinary(char op, NetExpr*l, NetExpr*r) -: op_(op), left_(l), right_(r) +NetEBinary::NetEBinary(char op__, NetExpr*l, NetExpr*r) +: op_(op__), left_(l), right_(r) { // Binary expressions of all sorts are signed if both the // arguments are signed. @@ -2095,8 +2095,8 @@ NetEBinary* NetEBinary::dup_expr() const return 0; } -NetEBLogic::NetEBLogic(char op, NetExpr*l, NetExpr*r) -: NetEBinary(op, l, r) +NetEBLogic::NetEBLogic(char op__, NetExpr*l, NetExpr*r) +: NetEBinary(op__, l, r) { expr_width(1); } @@ -2317,8 +2317,8 @@ ivl_variable_type_t NetETernary::expr_type() const return tru; } -NetEUnary::NetEUnary(char op, NetExpr*ex) -: NetExpr(ex->expr_width()), op_(op), expr_(ex) +NetEUnary::NetEUnary(char op__, NetExpr*ex) +: NetExpr(ex->expr_width()), op_(op__), expr_(ex) { switch (op_) { case '!': @@ -2346,8 +2346,8 @@ ivl_variable_type_t NetEUnary::expr_type() const return expr_->expr_type(); } -NetEUBits::NetEUBits(char op, NetExpr*ex) -: NetEUnary(op, ex) +NetEUBits::NetEUBits(char op__, NetExpr*ex) +: NetEUnary(op__, ex) { } @@ -2360,8 +2360,8 @@ ivl_variable_type_t NetEUBits::expr_type() const return expr_->expr_type(); } -NetEUReduce::NetEUReduce(char op, NetExpr*ex) -: NetEUnary(op, ex) +NetEUReduce::NetEUReduce(char op__, NetExpr*ex) +: NetEUnary(op__, ex) { expr_width(1); } @@ -2395,9 +2395,9 @@ unsigned NetLogic::width() const return width_; } -NetUReduce::NetUReduce(NetScope*scope, perm_string n, +NetUReduce::NetUReduce(NetScope*scope__, perm_string n, NetUReduce::TYPE t, unsigned wid) -: NetNode(scope, n, 2), type_(t), width_(wid) +: NetNode(scope__, n, 2), type_(t), width_(wid) { pin(0).set_dir(Link::OUTPUT); pin(1).set_dir(Link::INPUT); diff --git a/netlist.h b/netlist.h index ed8e16333..359b3eadd 100644 --- a/netlist.h +++ b/netlist.h @@ -728,7 +728,7 @@ class NetScope : public Attrib { bool in_func(); /* Is the task or function automatic. */ - void is_auto(bool is_auto) { is_auto_ = is_auto; }; + void is_auto(bool is_auto__) { is_auto_ = is_auto__; }; bool is_auto() const { return is_auto_; }; const NetTaskDef* task_def() const; diff --git a/vvp/array.cc b/vvp/array.cc index 936ca9c12..b480b6004 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -1026,7 +1026,7 @@ void array_word_change(vvp_array_t array, unsigned long addr) class array_port_resolv_list_t : public resolv_list_s { public: - explicit array_port_resolv_list_t(char*label) : resolv_list_s(label) { } + explicit array_port_resolv_list_t(char*lab) : resolv_list_s(lab) { } vvp_net_t*ptr; bool use_addr; @@ -1063,9 +1063,9 @@ void vpip_array_word_change(struct __vpiCallback*cb, vpiHandle obj) unsigned addr = decode_array_word_pointer(word, parent); cb->extra_data = addr; - } else if (struct __vpiArrayVthrA*word = array_vthr_a_from_handle(obj)) { - parent = word->array; - cb->extra_data = word->address; + } else if (struct __vpiArrayVthrA*tword = array_vthr_a_from_handle(obj)) { + parent = tword->array; + cb->extra_data = tword->address; } assert(parent); diff --git a/vvp/compile.cc b/vvp/compile.cc index 672b6e08e..28ce20ce4 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -425,7 +425,7 @@ void functor_ref_lookup(vvp_net_t**ref, char*lab) */ struct vpi_handle_resolv_list_s: public resolv_list_s { - explicit vpi_handle_resolv_list_s(char*label) : resolv_list_s(label) { } + explicit vpi_handle_resolv_list_s(char*lab) : resolv_list_s(lab) { } virtual bool resolve(bool mes); vpiHandle *handle; }; @@ -524,7 +524,7 @@ void compile_vpi_lookup(vpiHandle *handle, char*label) */ struct code_label_resolv_list_s: public resolv_list_s { - code_label_resolv_list_s(char*label) : resolv_list_s(label) { } + code_label_resolv_list_s(char*lab) : resolv_list_s(lab) { } struct vvp_code_s *code; virtual bool resolve(bool mes); }; @@ -557,7 +557,7 @@ void code_label_lookup(struct vvp_code_s *code, char *label) } struct code_array_resolv_list_s: public resolv_list_s { - code_array_resolv_list_s(char*label) : resolv_list_s(label) { } + code_array_resolv_list_s(char*lab) : resolv_list_s(lab) { } struct vvp_code_s *code; virtual bool resolve(bool mes); }; diff --git a/vvp/ufunc.cc b/vvp/ufunc.cc index 4570a0275..caa7d78de 100644 --- a/vvp/ufunc.cc +++ b/vvp/ufunc.cc @@ -37,7 +37,7 @@ ufunc_core::ufunc_core(unsigned owid, vvp_net_t*ptr, unsigned nports, vvp_net_t**ports, - vvp_code_t sa, struct __vpiScope*call_scope, + vvp_code_t sa, struct __vpiScope*call_scope__, char*result_label, char*scope_label) : vvp_wide_fun_core(ptr, nports) { @@ -45,7 +45,7 @@ ufunc_core::ufunc_core(unsigned owid, vvp_net_t*ptr, ports_ = ports; code_ = sa; thread_ = 0; - call_scope_ = call_scope; + call_scope_ = call_scope__; functor_ref_lookup(&result_, result_label); diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 3bb7bd353..4a0b89249 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -3762,8 +3762,8 @@ bool of_POW(vthread_t thr, vvp_code_t cp) /* If we have an X or Z in the arguments return X. */ if (xv2.is_NaN() || yv2.is_NaN()) { - for (unsigned idx = 0 ; idx < wid ; idx += 1) - thr_put_bit(thr, cp->bit_idx[0]+idx, BIT4_X); + for (unsigned jdx = 0 ; jdx < wid ; jdx += 1) + thr_put_bit(thr, cp->bit_idx[0]+jdx, BIT4_X); return true; } @@ -3775,15 +3775,15 @@ bool of_POW(vthread_t thr, vvp_code_t cp) /* If the result is too small zero pad it. */ if (result.size() < wid) { - for (unsigned idx = wid-1; idx >= result.size(); idx -= 1) - thr_put_bit(thr, cp->bit_idx[0]+idx, BIT4_0); + for (unsigned jdx = wid-1; jdx >= result.size(); jdx -= 1) + thr_put_bit(thr, cp->bit_idx[0]+jdx, BIT4_0); wid = result.size(); } /* Copy only what we need of the result. */ - for (unsigned idx = 0; idx < wid; idx += 1) - thr_put_bit(thr, cp->bit_idx[0]+idx, - result.value(idx) ? BIT4_1 : BIT4_0); + for (unsigned jdx = 0; jdx < wid; jdx += 1) + thr_put_bit(thr, cp->bit_idx[0]+jdx, + result.value(jdx) ? BIT4_1 : BIT4_0); return true; } diff --git a/vvp/vvp_island.cc b/vvp/vvp_island.cc index c258309a6..411aadcda 100644 --- a/vvp/vvp_island.cc +++ b/vvp/vvp_island.cc @@ -237,6 +237,7 @@ void vvp_island::add_port(const char*key, vvp_net_t*net) void vvp_island::add_branch(vvp_island_branch*branch, const char*pa, const char*pb) { + vvp_island_branch*cur; assert(ports_); branch->a = ports_->sym_get_value(pa); branch->b = ports_->sym_get_value(pb); @@ -249,10 +250,10 @@ void vvp_island::add_branch(vvp_island_branch*branch, const char*pa, const char* if (bnodes_ == 0) bnodes_ = new symbol_map_s; - if (vvp_island_branch*cur = anodes_->sym_get_value(pa)) { + if ((cur = anodes_->sym_get_value(pa))) { branch->link[0] = cur->link[0]; cur->link[0] = ptra; - } else if (vvp_island_branch*cur = bnodes_->sym_get_value(pa)) { + } else if ((cur = bnodes_->sym_get_value(pa))) { branch->link[0] = cur->link[1]; cur->link[1] = ptra; } else { @@ -260,10 +261,10 @@ void vvp_island::add_branch(vvp_island_branch*branch, const char*pa, const char* anodes_->sym_set_value(pa, branch); } - if (vvp_island_branch*cur = anodes_->sym_get_value(pb)) { + if ((cur = anodes_->sym_get_value(pb))) { branch->link[1] = cur->link[0]; cur->link[0] = ptrb; - } else if (vvp_island_branch*cur = bnodes_->sym_get_value(pb)) { + } else if ((cur = bnodes_->sym_get_value(pb))) { branch->link[1] = cur->link[1]; cur->link[1] = ptrb; } else { diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index bff6765f3..b998e13b7 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -382,8 +382,8 @@ void vvp_vector4_t::allocate_words_(unsigned wid, unsigned long inita, unsigned } } -vvp_vector4_t::vvp_vector4_t(unsigned size, double val) -: size_(size) +vvp_vector4_t::vvp_vector4_t(unsigned size__, double val) +: size_(size__) { bool is_neg = false; double fraction; @@ -391,7 +391,7 @@ vvp_vector4_t::vvp_vector4_t(unsigned size, double val) /* We return 'bx for a NaN or +/- infinity. */ if (val != val || (val && (val == 0.5*val))) { - allocate_words_(size, WORD_X_ABITS, WORD_X_BBITS); + allocate_words_(size_, WORD_X_ABITS, WORD_X_BBITS); return; } @@ -400,7 +400,7 @@ vvp_vector4_t::vvp_vector4_t(unsigned size, double val) is_neg = true; val = -val; } - allocate_words_(size, WORD_0_ABITS, WORD_0_BBITS); + allocate_words_(size_, WORD_0_ABITS, WORD_0_BBITS); /* Get the exponent and fractional part of the number. */ fraction = frexp(val, &exponent); @@ -1298,9 +1298,9 @@ bool vector4_to_value(const vvp_vector4_t&vec, double&val, bool signed_flag) return flag; } -vvp_vector4array_t::vvp_vector4array_t(unsigned width, unsigned words, +vvp_vector4array_t::vvp_vector4array_t(unsigned width__, unsigned words__, bool is_automatic) -: width_(width), words_(words), array_(0) +: width_(width__), words_(words__), array_(0) { if (is_automatic) return; diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index d5d40fbe4..24b888c85 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -289,8 +289,8 @@ inline vvp_vector4_t::vvp_vector4_t(const vvp_vector4_t&that) copy_from_(that); } -inline vvp_vector4_t::vvp_vector4_t(unsigned size, vvp_bit4_t val) -: size_(size) +inline vvp_vector4_t::vvp_vector4_t(unsigned size__, vvp_bit4_t val) +: size_(size__) { /* note: this relies on the bit encoding for the vvp_bit4_t. */ const static unsigned long init_atable[4] = { @@ -304,7 +304,7 @@ inline vvp_vector4_t::vvp_vector4_t(unsigned size, vvp_bit4_t val) WORD_Z_BBITS, WORD_X_BBITS }; - allocate_words_(size, init_atable[val], init_btable[val]); + allocate_words_(size_, init_atable[val], init_btable[val]); } inline vvp_vector4_t::~vvp_vector4_t() @@ -750,8 +750,8 @@ extern vvp_vector8_t part_expand(const vvp_vector8_t&a, unsigned wid, unsigned o /* Print a vector8 value to a stream. */ extern ostream& operator<< (ostream&, const vvp_vector8_t&); -inline vvp_vector8_t::vvp_vector8_t(unsigned size) -: size_(size) +inline vvp_vector8_t::vvp_vector8_t(unsigned size__) +: size_(size__) { if (size_ <= PTR_THRESH) { new (val_) vvp_scalar_t[PTR_THRESH]; @@ -822,12 +822,12 @@ template class vvp_sub_pointer_t { public: vvp_sub_pointer_t() : bits_(0) { } - vvp_sub_pointer_t(T*ptr, unsigned port) + vvp_sub_pointer_t(T*ptr__, unsigned port__) { - bits_ = reinterpret_cast (ptr); - assert( (bits_ & 3) == 0 ); - assert( (port & ~3) == 0 ); - bits_ |= port; + bits_ = reinterpret_cast (ptr__); + assert( (bits_ & 3) == 0 ); + assert( (port__ & ~3) == 0 ); + bits_ |= port__; } ~vvp_sub_pointer_t() { }