diff --git a/cprop.cc b/cprop.cc index 4dab26138..9e7864b09 100644 --- a/cprop.cc +++ b/cprop.cc @@ -194,7 +194,7 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj) count += 1; } -static bool compare_base(NetPartSelect*a, NetPartSelect*b) +static bool compare_base(const NetPartSelect*a, const NetPartSelect*b) { return a->base() < b->base(); } diff --git a/net_design.cc b/net_design.cc index bddb53568..ab1002323 100644 --- a/net_design.cc +++ b/net_design.cc @@ -124,9 +124,9 @@ NetScope* Design::find_root_scope() return root_scopes_.front(); } -list Design::find_root_scopes() const +list&Design::find_root_scopes() const { - return root_scopes_; + return const_cast&>(root_scopes_); } NetScope* Design::make_package_scope(perm_string name, NetScope*unit_scope, diff --git a/netlist.h b/netlist.h index 903ceb58f..57b69959c 100644 --- a/netlist.h +++ b/netlist.h @@ -5090,7 +5090,7 @@ class Design { NetScope* make_root_scope(perm_string name, NetScope*unit_scope, bool program_block, bool is_interface); NetScope* find_root_scope(); - std::list find_root_scopes() const; + std::list&find_root_scopes() const; NetScope* make_package_scope(perm_string name, NetScope*unit_scope, bool is_unit); diff --git a/verinum.cc b/verinum.cc index d4213a670..713ca7d55 100644 --- a/verinum.cc +++ b/verinum.cc @@ -1478,9 +1478,10 @@ verinum operator / (const verinum&left, const verinum&right) long r = right.as_long(); bool overflow = (l == LONG_MIN) && (r == -1); long v = overflow ? LONG_MIN : l / r; + unsigned long uv = v; for (unsigned idx = 0 ; idx < use_len ; idx += 1) { - result.set(idx, (v & 1)? verinum::V1 : verinum::V0); - v >>= 1; + result.set(idx, (uv & 1)? verinum::V1 : verinum::V0); + uv >>= 1; } } else { diff --git a/vpi/cppcheck.sup b/vpi/cppcheck.sup index 20661dde7..bf5a0eb6a 100644 --- a/vpi/cppcheck.sup +++ b/vpi/cppcheck.sup @@ -4,6 +4,16 @@ nullPointerArithmeticOutOfMemory nullPointerOutOfMemory memleakOnRealloc +// Skip asctime() obsolete for now. +asctimeCalled:sys_fst.c:381 +asctimeCalled:sys_vcd.c:443 + +// Skip since table_model() is not complete. +memleak:table_mod.c:225 +memleak:table_mod.c:230 +memleak:table_mod.c:243 +resourceLeak:table_mod.c:607 + // Skip strdup() not constant. constVariablePointer:sys_vcd.c:631 constVariablePointer:sys_vcd.c:688 diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 3b1ed97ee..d7e11fff9 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2026 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 @@ -365,10 +365,10 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus, vpi_printf("WARNING: %s:%d: incompatible value for %s%s.\n", info->filename, info->lineno, info->name, fmtb); } else { - unsigned swidth = strlen(value.value.str), free_flag = 0;; + unsigned free_flag = 0; char *cp = value.value.str; - if (ld_zero == 1) { + unsigned swidth = strlen(value.value.str); /* Strip the leading zeros if a width is not given. */ if (width == -1) while (*cp == '0' && *(cp+1) != '\0') cp++; /* Pad with leading zeros. */ diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index 76ec458ba..61886c515 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2025 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2026 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 @@ -68,7 +68,7 @@ static struct vcd_info*new_vcd_info(void) struct vcd_info_chunk*tmp = calloc(1, sizeof(struct vcd_info_chunk)); tmp->chunk_fill = 0; tmp->chunk_next = cur_chunk; - info_chunk_list = cur_chunk = tmp; + info_chunk_list = tmp; return info_chunk_list->data + 0; } @@ -104,7 +104,7 @@ static void delete_all_vcd_info(void) * if they are in the list already, even if they are at the end of the * list. */ -# define VCD_INFO_ENDP ((struct vcd_info*)1) +#define VCD_INFO_ENDP ((struct vcd_info*)(uintptr_t) 0x01) static struct vcd_info *vcd_dmp_list = VCD_INFO_ENDP; static PLI_UINT64 vcd_cur_time = 0; @@ -182,7 +182,7 @@ static char *create_full_name(const char *name) char *n, *n2; int len = 0; int is_esc_id = is_escaped_id(name); - struct lxt_scope *t = lxt_scope_head; + const struct lxt_scope *t = lxt_scope_head; /* Figure out how long the combined string will be. */ while(t) { diff --git a/vvp/array.cc b/vvp/array.cc index 1b4c45cdf..2e9317b4d 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -1278,8 +1278,8 @@ static void array_attach_port(vvp_array_t array, vvp_fun_arrayport*fun) class array_word_value_callback : public value_callback { public: - inline explicit array_word_value_callback(p_cb_data data) - : value_callback(data) + inline explicit array_word_value_callback(p_cb_data data, long addr) + : value_callback(data), word_addr(addr) { } public: @@ -1442,7 +1442,7 @@ bool array_port_resolv_list_t::resolve(bool mes) class array_word_part_callback : public array_word_value_callback { public: - explicit array_word_part_callback(p_cb_data data); + explicit array_word_part_callback(p_cb_data data, long addr); ~array_word_part_callback() override; array_word_part_callback(const array_word_part_callback&) = delete; @@ -1454,8 +1454,8 @@ class array_word_part_callback : public array_word_value_callback { char*value_bits_; }; -array_word_part_callback::array_word_part_callback(p_cb_data data) -: array_word_value_callback(data) +array_word_part_callback::array_word_part_callback(p_cb_data data, long addr) +: array_word_value_callback(data, addr) { // Get the initial value of the part, to use as a reference. struct __vpiArrayVthrAPV*apvword = dynamic_cast<__vpiArrayVthrAPV*>(data->obj); @@ -1500,18 +1500,15 @@ value_callback*vpip_array_word_change(p_cb_data data) if (const struct __vpiArrayWord*word = array_var_word_from_handle(data->obj)) { parent = static_cast<__vpiArray*>(word->get_parent()); unsigned addr = word->get_index(); - cbh = new array_word_value_callback(data); - cbh->word_addr = addr; + cbh = new array_word_value_callback(data, addr); } else if (struct __vpiArrayVthrA*tword = dynamic_cast<__vpiArrayVthrA*>(data->obj)) { parent = tword->array; - cbh = new array_word_value_callback(data); - cbh->word_addr = tword->address; + cbh = new array_word_value_callback(data, tword->address); } else if (struct __vpiArrayVthrAPV*apvword = dynamic_cast<__vpiArrayVthrAPV*>(data->obj)) { parent = apvword->array; - cbh = new array_word_part_callback(data); - cbh->word_addr = apvword->word_sel; + cbh = new array_word_part_callback(data, apvword->word_sel); } assert(cbh); @@ -1524,11 +1521,10 @@ value_callback*vpip_array_word_change(p_cb_data data) value_callback* vpip_array_change(p_cb_data data) { - array_word_value_callback*cbh = new array_word_value_callback(data); + array_word_value_callback*cbh = new array_word_value_callback(data, -1); assert(data->obj); struct __vpiArray*arr = dynamic_cast<__vpiArray*>(data->obj); - cbh->word_addr = -1; // This is a callback for every element. cbh->next = arr->vpi_callbacks; arr->vpi_callbacks = cbh; return cbh; diff --git a/vvp/class_type.cc b/vvp/class_type.cc index 73fefd95e..034ac768d 100644 --- a/vvp/class_type.cc +++ b/vvp/class_type.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-2026 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 @@ -36,7 +36,7 @@ using namespace std; */ class class_property_t { public: - inline class_property_t() { } + inline class_property_t() { offset_ = 0; } virtual ~class_property_t() =0; // How much space does an instance of this property require? virtual size_t instance_size() const =0; diff --git a/vvp/cppcheck.sup b/vvp/cppcheck.sup index 4ae4f3cf3..21bfc4bac 100644 --- a/vvp/cppcheck.sup +++ b/vvp/cppcheck.sup @@ -12,9 +12,91 @@ nullPointerOutOfMemory // Only for conditional debugging knownConditionTrueFalse:lib_main.cc:289 +// For now these casts have to be used +dangerousTypeCast:array_common.cc:188 +dangerousTypeCast:array_common.cc:201 +invalidPointerCast:class_type.cc:203 +invalidPointerCast:class_type.cc:326 +invalidPointerCast:class_type.cc:332 +invalidPointerCast:class_type.cc:338 +invalidPointerCast:class_type.cc:339 +cstyleCast:ufunc.cc:80 + +// Skip the sscanf() field width limit warning +invalidscanf:compile.cc:597 +invalidscanf:compile.cc:609 + // By convention we put statics at the top scope. variableScope:vpi_priv.cc:623 +// Operator new/delete are static so cannot override +duplInheritedMember:vvp_net.h:1476 +duplInheritedMember:vvp_net.h:1477 +duplInheritedMember:vvp_net_sig.h:187 +duplInheritedMember:vvp_net_sig.h:188 +duplInheritedMember:vvp_net_sig.h:253 +duplInheritedMember:vvp_net_sig.h:254 +duplInheritedMember:vvp_net_sig.h:313 +duplInheritedMember:vvp_net_sig.h:314 +duplInheritedMember:vvp_net_sig.h:377 +duplInheritedMember:vvp_net_sig.h:378 +duplInheritedMember:vvp_net_sig.cc:442 +duplInheritedMember:vvp_net_sig.cc:580 +duplInheritedMember:vvp_net_sig.cc:585 +duplInheritedMember:vvp_net_sig.cc:697 +duplInheritedMember:vvp_net_sig.cc:702 +duplInheritedMember:vvp_net_sig.cc:810 +duplInheritedMember:vvp_net_sig.cc:815 +duplInheritedMember:schedule.cc:143 +duplInheritedMember:schedule.cc:149 +duplInheritedMember:schedule.cc:212 +duplInheritedMember:schedule.cc:218 +duplInheritedMember:schedule.cc:249 +duplInheritedMember:schedule.cc:255 +duplInheritedMember:schedule.cc:286 +duplInheritedMember:schedule.cc:292 +duplInheritedMember:schedule.cc:319 +duplInheritedMember:schedule.cc:325 +duplInheritedMember:schedule.cc:391 +duplInheritedMember:schedule.cc:397 +duplInheritedMember:schedule.cc:480 +duplInheritedMember:schedule.cc:486 +duplInheritedMember:schedule.cc:521 +duplInheritedMember:schedule.cc:527 + +// The derived class calls the base class routine and uses private inheritance +duplInheritedMember:symbols.h:112 + +// This is not always true +duplicateValueTernary:class_type.cc:268 + +// cppcheck is wrong this can be true or false +knownConditionTrueFalse:vthread.cc:2986 + +// cppcheck does not relize this is deleted[] in the called routine +leakNoVarFunctionCall:compile.cc:452 + +// Yes, these are not currently initialized in the constructor +// All are added after __vpiSysTaskCall is built +uninitMemberVar:vpi_priv.h:944 +// All are added after __vpiSignal is built +uninitMemberVar:vpi_priv.h:392 +// run_run_ptr is added after the event is built +uninitMemberVar:delay.h:79 +// The array values are added after it is allocated +noConstructor:vpi_priv.h:778 +// The enum values are added after this is built +uninitMemberVar:enum_type.cc:54 +// The names for the enum values are added after allocation +uninitMemberVar:enum_type.cc:100 +// The thread values get assigned after being created +uninitMemberVar:vthread.cc:316 +// The mod path has the values added after creation +uninitMemberVar:delay.cc:1005 +uninitMemberVar:delay.cc:1045 +// The intermod path has the values added after creation +uninitMemberVar:delay.cc:1395 + // Index calculation thisSubtraction:vpi_priv.h:430 thisSubtraction:array_common.h:91 diff --git a/vvp/symbols.h b/vvp/symbols.h index d5ad46c27..d20886b49 100644 --- a/vvp/symbols.h +++ b/vvp/symbols.h @@ -57,6 +57,7 @@ class symbol_table_s { public: explicit symbol_table_s(); virtual ~symbol_table_s(); + symbol_table_s(const symbol_table_s&) = delete; symbol_table_s& operator=(const symbol_table_s&) = delete; // This method locates the value in the symbol table and sets its @@ -69,7 +70,6 @@ class symbol_table_s { symbol_value_t sym_get_value(const char*key); private: - symbol_table_s(const symbol_table_s&) { assert(0); }; struct tree_node_*root; struct key_strings*str_chunk; unsigned str_used; diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index 5749f711a..5d0e77e2f 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -1473,8 +1473,8 @@ class vvp_wide_fun_core : public vvp_net_fun_t { vvp_wide_fun_core(vvp_net_t*net, unsigned nports); virtual ~vvp_wide_fun_core() override; // These objects are not perm allocated. - void* operator new(std::size_t size) { return ::new char[size]; } - void operator delete(void* ptr) { ::delete[](static_cast(ptr)); } + static void* operator new(std::size_t size) { return ::new char[size]; } + static void operator delete(void* ptr) { ::delete[](static_cast(ptr)); } protected: void propagate_vec4(const vvp_vector4_t&bit, vvp_time64_t delay =0); diff --git a/vvp/vvp_net_sig.h b/vvp/vvp_net_sig.h index c93b37033..ee65b9f62 100644 --- a/vvp/vvp_net_sig.h +++ b/vvp/vvp_net_sig.h @@ -1,7 +1,7 @@ #ifndef IVL_vvp_net_sig_H #define IVL_vvp_net_sig_H /* - * Copyright (c) 2004-2025 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2026 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 @@ -264,9 +264,6 @@ class vvp_fun_signal_string : public vvp_fun_signal_base { explicit vvp_fun_signal_string() {}; virtual const std::string& get_string() const =0; - - protected: - std::string value_; }; /*