diff --git a/tgt-fpga/d-lpm.c b/tgt-fpga/d-lpm.c index 6f7b84e602..e1610e5334 100644 --- a/tgt-fpga/d-lpm.c +++ b/tgt-fpga/d-lpm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2021 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 @@ -553,7 +553,7 @@ static void lpm_show_mux(ivl_lpm_t net) edif_cellref_t ref; edif_joint_t jnt; - unsigned idx, rdx; + unsigned idx; char cellname[32]; @@ -626,6 +626,7 @@ static void lpm_show_mux(ivl_lpm_t net) } for (idx = 0 ; idx < wid_z ; idx += 1) { + unsigned rdx; for (rdx = 0 ; rdx < wid_r ; rdx += 1) { unsigned pin; diff --git a/tgt-fpga/mangle.c b/tgt-fpga/mangle.c index ac3b66fdf6..0749d5cc74 100644 --- a/tgt-fpga/mangle.c +++ b/tgt-fpga/mangle.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2021 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 @@ -30,9 +30,7 @@ static size_t xnf_mangle_scope_name(ivl_scope_t net, char*buf, size_t nbuf) if (parent) { cnt = xnf_mangle_scope_name(parent, buf, nbuf); buf += cnt; - nbuf -= cnt; *buf++ = '/'; - nbuf -= 1; cnt += 1; } diff --git a/tgt-stub/cppcheck.sup b/tgt-stub/cppcheck.sup index a4a512adbf..70b13cdf16 100644 --- a/tgt-stub/cppcheck.sup +++ b/tgt-stub/cppcheck.sup @@ -2,7 +2,7 @@ // are not used here. // target_design() -unusedFunction:stub.c:1774 +unusedFunction:stub.c:1837 // target_query() -unusedFunction:stub.c:1844 +unusedFunction:stub.c:1907 diff --git a/tgt-stub/expression.c b/tgt-stub/expression.c index 569c7e6e4d..bcec38ee8d 100644 --- a/tgt-stub/expression.c +++ b/tgt-stub/expression.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 2007-2021 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 @@ -75,7 +75,7 @@ static void show_branch_access_expression(ivl_expr_t net, unsigned ind) } ivl_discipline_t tb_disc = discipline_of_nexus(tb); - if (ta_disc == 0) { + if (tb_disc == 0) { fprintf(out, "%*sERROR: Reference terminal of branch has no discipline\n", ind, ""); stub_errors += 1; diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 8f8c1834c4..670962f7a8 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2021 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 @@ -1427,7 +1427,7 @@ static void show_signal(ivl_signal_t net) fprintf(out, " %s %s %s", type, sign, port); show_type_of_signal(net); - fprintf(out, " %s[word=%u, adr=%d] ", + fprintf(out, " %s[word=%u, adr=%u] ", ivl_signal_basename(net), idx, ivl_signal_array_base(net)+idx, ivl_signal_width(net), diff --git a/tgt-verilog/cppcheck.sup b/tgt-verilog/cppcheck.sup index f10e95e549..aa6eeeab62 100644 --- a/tgt-verilog/cppcheck.sup +++ b/tgt-verilog/cppcheck.sup @@ -2,4 +2,4 @@ // are not used here. // target_design() -unusedFunction:verilog.c:408 +unusedFunction:verilog.c:411 diff --git a/tgt-vhdl/vhdl_element.cc b/tgt-vhdl/vhdl_element.cc index 1b5c451918..7aa7e42989 100644 --- a/tgt-vhdl/vhdl_element.cc +++ b/tgt-vhdl/vhdl_element.cc @@ -1,7 +1,7 @@ /* * VHDL abstract syntax elements. * - * Copyright (C) 2008-2011 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,7 +66,7 @@ vector vhdl_element::allocated_; // Just a counter of total bytes allocated for statistics size_t vhdl_element::total_alloc_(0); -void vhdl_element::set_comment(std::string comment) +void vhdl_element::set_comment(const std::string&comment) { comment_ = comment; } diff --git a/tgt-vhdl/vhdl_element.hh b/tgt-vhdl/vhdl_element.hh index 8cf11d4cfa..14d3311265 100644 --- a/tgt-vhdl/vhdl_element.hh +++ b/tgt-vhdl/vhdl_element.hh @@ -1,7 +1,7 @@ /* * VHDL abstract syntax elements. * - * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,7 +52,7 @@ public: virtual void emit(std::ostream &of, int level=0) const = 0; void print() const; - void set_comment(std::string comment); + void set_comment(const std::string&comment); static int free_all_objects(); static size_t total_allocated(); diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index 7efecbaf81..32edec1ac8 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -1,7 +1,7 @@ /* * VHDL abstract syntax elements. * - * Copyright (C) 2008-2013 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ typedef set vhdl_var_set_t; class vhdl_expr : public vhdl_element { public: - vhdl_expr(const vhdl_type* type, bool isconst=false) + explicit vhdl_expr(const vhdl_type* type, bool isconst=false) : type_(type), isconst_(isconst) {} virtual ~vhdl_expr(); @@ -227,7 +227,7 @@ enum time_unit_t { class vhdl_const_time : public vhdl_expr { public: - vhdl_const_time(uint64_t value, time_unit_t units = TIME_UNIT_NS) + explicit vhdl_const_time(uint64_t value, time_unit_t units = TIME_UNIT_NS) : vhdl_expr(vhdl_type::time(), true), value_(value), units_(units) {} void emit(std::ostream &of, int level) const; private: @@ -464,8 +464,8 @@ enum vhdl_severity_t { class vhdl_report_stmt : public vhdl_seq_stmt { public: - vhdl_report_stmt(vhdl_expr *text, - vhdl_severity_t severity = SEVERITY_NOTE); + explicit vhdl_report_stmt(vhdl_expr *text, + vhdl_severity_t severity = SEVERITY_NOTE); virtual ~vhdl_report_stmt() {} virtual void emit(ostream& of, int level) const; @@ -602,8 +602,8 @@ private: */ class vhdl_decl : public vhdl_element { public: - vhdl_decl(const string& name, const vhdl_type *type = NULL, - vhdl_expr *initial = NULL) + explicit vhdl_decl(const string& name, const vhdl_type *type = NULL, + vhdl_expr *initial = NULL) : name_(name), type_(type), initial_(initial), has_initial_(initial != NULL) {} virtual ~vhdl_decl(); diff --git a/tgt-vhdl/vhdl_type.cc b/tgt-vhdl/vhdl_type.cc index cd45d51644..2b6743842d 100644 --- a/tgt-vhdl/vhdl_type.cc +++ b/tgt-vhdl/vhdl_type.cc @@ -1,7 +1,7 @@ /* * VHDL variable and signal types. * - * Copyright (C) 2008-2013 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -188,7 +188,7 @@ vhdl_type *vhdl_type::type_for(int width, bool issigned, return vhdl_type::nunsigned(width, lsb); } -vhdl_type *vhdl_type::array_of(vhdl_type *b, std::string &n, int m, int l) +vhdl_type *vhdl_type::array_of(vhdl_type *b, const std::string &n, int m, int l) { return new vhdl_type(b, n, m, l); } diff --git a/tgt-vhdl/vhdl_type.hh b/tgt-vhdl/vhdl_type.hh index c374584a77..7039f39257 100644 --- a/tgt-vhdl/vhdl_type.hh +++ b/tgt-vhdl/vhdl_type.hh @@ -1,7 +1,7 @@ /* * VHDL variable and signal types. * - * Copyright (C) 2008-2010 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,7 +46,7 @@ enum vhdl_type_name_t { class vhdl_type : public vhdl_element { public: // Scalar constructor - vhdl_type(vhdl_type_name_t name, int msb = 0, int lsb = 0) + explicit vhdl_type(vhdl_type_name_t name, int msb = 0, int lsb = 0) : name_(name), msb_(msb), lsb_(lsb), base_(NULL) {} // Array constructor @@ -84,7 +84,7 @@ public: static vhdl_type *type_for(int width, bool issigned, int lsb=0, bool unresolved=false); - static vhdl_type *array_of(vhdl_type *b, std::string &n, int m, int l); + static vhdl_type *array_of(vhdl_type *b, const std::string &n, int m, int l); protected: vhdl_type_name_t name_; int msb_, lsb_; diff --git a/tgt-vlog95/cppcheck.sup b/tgt-vlog95/cppcheck.sup index 0f6bb9fc00..956fbb96a5 100644 --- a/tgt-vlog95/cppcheck.sup +++ b/tgt-vlog95/cppcheck.sup @@ -5,4 +5,4 @@ unusedFunction:vlog95.c:59 // target_query() -unusedFunction:vlog95.c:251 +unusedFunction:vlog95.c:257 diff --git a/tgt-vlog95/numbers.c b/tgt-vlog95/numbers.c index fd28b83dfc..4ba0ee7e87 100644 --- a/tgt-vlog95/numbers.c +++ b/tgt-vlog95/numbers.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2014 Cary R. (cygcary@yahoo.com) + * Copyright (C) 2011-2021 Cary R. (cygcary@yahoo.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,7 +65,7 @@ static int32_t get_int32_from_bits(const char *bits, unsigned nbits, // HERE: Need to emit 1 instead of -1 for some of the constants. // if (is_signed && (nbits > 1) && (msb == '1') && (trim_wid < 32U)) { if (is_signed && (msb == '1') && (trim_wid < 32U)) { - value |= ~(((int32_t)1 << trim_wid) - (int32_t)1); + value |= ~(((uint32_t)1 << trim_wid) - (uint32_t)1); } *result_type = 0; return value; @@ -309,7 +309,7 @@ int64_t get_int64_from_number(ivl_expr_t expr, int *result_type) } /* Sign extend as needed. */ if (is_signed && (msb == '1') && (trim_wid < 64U)) { - value |= ~(((int64_t)1 << trim_wid) - (int64_t)1); + value |= ~(((uint64_t)1 << trim_wid) - (uint64_t)1); } *result_type = 0; return value; diff --git a/tgt-vvp/cppcheck.sup b/tgt-vvp/cppcheck.sup index 9f6d9483ee..efd39acf9e 100644 --- a/tgt-vvp/cppcheck.sup +++ b/tgt-vvp/cppcheck.sup @@ -2,7 +2,7 @@ // are not used here. // target_design() -unusedFunction:vvp.c:148 +unusedFunction:vvp.c:152 // target_query() -unusedFunction:vvp.c:246 +unusedFunction:vvp.c:250