Some cppcheck cleanup

This commit is contained in:
Cary R 2025-10-12 17:35:15 -07:00
parent d79e49a372
commit fcb543d6e5
49 changed files with 184 additions and 159 deletions

4
cppcheck-global.sup Normal file
View File

@ -0,0 +1,4 @@
// Skip all messages about missing system include files
missingIncludeSystem
// Skip the active checker report message
checkersReport

View File

@ -59,6 +59,8 @@ distclean: clean
cppcheck: $(O:.o=.cc)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -57,6 +57,8 @@ distclean: clean
cppcheck: $(O:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -62,6 +62,8 @@ distclean: clean
cppcheck: $(O:.o=.cc)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
-UYY_USER_INIT \
-UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 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,7 +30,7 @@ static void show_pcb_header(FILE*fpcb)
fprintf(fpcb, "Grid[100.0 0 0 1]\n");
}
static void show_pcb_element(FILE*fpcb, const string&refdes, element_data_t*elem);
static void show_pcb_element(FILE*fpcb, const string&refdes, const element_data_t*elem);
void show_pcb(const char*pcb_path)
{
@ -53,7 +53,7 @@ void show_pcb(const char*pcb_path)
fclose(fpcb);
}
static void show_pcb_element(FILE*fpcb, const string&refdes, element_data_t*elem)
static void show_pcb_element(FILE*fpcb, const string&refdes, const element_data_t*elem)
{
string descr = elem->description;
const string&value = elem->value;

View File

@ -57,6 +57,8 @@ distclean: clean
cppcheck: $(O:.o=.cc)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2014-2025 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
@ -56,7 +56,7 @@ FILE*sizer_out = 0;
static int process_scan_fun(ivl_process_t net, void*raw);
static void emit_sizer_scope(ivl_design_t des, ivl_scope_t model, struct sizer_statistics&stats);
static void show_stats(struct sizer_statistics&stats);
static void show_stats(const struct sizer_statistics&stats);
/*
* This is called by the ivl core to get version information from the
@ -149,7 +149,7 @@ static void emit_sizer_scope(ivl_design_t des, ivl_scope_t scope, struct sizer_s
}
}
static void show_stats(struct sizer_statistics&stats)
static void show_stats(const struct sizer_statistics&stats)
{
fprintf(sizer_out, " Flip-Flops : %u\n", stats.flop_count);
fprintf(sizer_out, " Logic Gates : %u\n", stats.gate_count);

View File

@ -58,6 +58,8 @@ distclean: clean
cppcheck: $(O:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 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
@ -503,7 +503,7 @@ static void show_lpm_concat(ivl_lpm_t net)
static void show_lpm_ff(ivl_lpm_t net)
{
ivl_nexus_t nex;
char*edge = ivl_lpm_negedge(net) ? "negedge" : "posedge";
const char*edge = ivl_lpm_negedge(net) ? "negedge" : "posedge";
unsigned width = ivl_lpm_width(net);
fprintf(out, " LPM_FF %s: <polarity=%s> <width=%u>\n",

View File

@ -61,6 +61,8 @@ distclean: clean
cppcheck: $(O:.o=.cc)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -1,7 +1,7 @@
/*
* Generate code to convert between VHDL types.
*
* Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* Copyright (C) 2008-2025 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
@ -90,8 +90,8 @@ vhdl_expr *vhdl_expr::to_vector(vhdl_type_name_t name, int w)
// We have to cast the expression before resizing or the
// wrong sign bit may be extended (i.e. when casting between
// signed/unsigned *and* resizing)
vhdl_type *t = new vhdl_type(name, w - 1, 0);
vhdl_fcall *conv = new vhdl_fcall(t->get_string().c_str(), t);
const vhdl_type *t = new vhdl_type(name, w - 1, 0);
vhdl_fcall *conv = new vhdl_fcall(t->get_string(), t);
conv->add_expr(this);
if (w != type_->get_width())
@ -229,7 +229,7 @@ vhdl_expr *vhdl_expr::to_std_ulogic()
*/
vhdl_expr *vhdl_expr::resize(int newwidth)
{
vhdl_type *rtype;
const vhdl_type *rtype;
assert(type_);
if (type_->get_name() == VHDL_TYPE_SIGNED)
rtype = vhdl_type::nsigned(newwidth);

View File

@ -220,7 +220,7 @@ static vhdl_expr *translate_numeric(vhdl_expr *lhs, vhdl_expr *rhs,
else if (rhs->get_type()->get_name() == VHDL_TYPE_BOOLEAN)
lhs = lhs->cast(&boolean);
vhdl_type *rtype;
const vhdl_type *rtype;
if (op == VHDL_BINOP_MULT)
rtype = new vhdl_type(lhs->get_type()->get_name(),
(lhs->get_type()->get_width()*2) - 1, 0);
@ -257,7 +257,7 @@ static vhdl_expr *translate_shift(vhdl_expr *lhs, vhdl_expr *rhs,
vhdl_type integer(VHDL_TYPE_INTEGER);
vhdl_expr *r_cast = rhs->cast(&integer);
vhdl_type *rtype = new vhdl_type(*lhs->get_type());
const vhdl_type *rtype = new vhdl_type(*lhs->get_type());
// The sra operator is not defined on numeric_std types until
// VHDL-2006 which is not well supported. Instead we can use
@ -297,7 +297,7 @@ static vhdl_expr *translate_power(ivl_expr_t e, vhdl_expr *lhs, vhdl_expr *rhs)
int width = ivl_expr_width(e);
const char *func = ivl_expr_signed(e) ? "To_Signed" : "To_Unsigned";
vhdl_type *type = ivl_expr_signed(e)
const vhdl_type *type = ivl_expr_signed(e)
? vhdl_type::nsigned(width) : vhdl_type::nunsigned(width);
vhdl_fcall *conv = new vhdl_fcall(func, type);
@ -554,7 +554,7 @@ static vhdl_expr *translate_ufunc(ivl_expr_t e)
const char *funcname = ivl_scope_tname(defscope);
vhdl_type *rettype =
const vhdl_type *rettype =
vhdl_type::type_for(ivl_expr_width(e), ivl_expr_signed(e) != 0);
vhdl_fcall *fcall = new vhdl_fcall(funcname, rettype);
@ -615,7 +615,7 @@ static vhdl_expr *translate_ternary(ivl_expr_t e)
static vhdl_expr *translate_concat(ivl_expr_t e)
{
vhdl_type *rtype =
const vhdl_type *rtype =
vhdl_type::type_for(ivl_expr_width(e), ivl_expr_signed(e) != 0);
vhdl_binop_expr *concat = new vhdl_binop_expr(VHDL_BINOP_CONCAT, rtype);

View File

@ -1,7 +1,7 @@
/*
* VHDL code generation for logic devices.
*
* Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* Copyright (C) 2008-2025 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
@ -118,7 +118,7 @@ static void comb_udp_logic(vhdl_arch *arch, ivl_net_logic_t log)
ostringstream ss;
ss << ivl_logic_basename(log) << "_Tmp";
int msb = ivl_udp_nin(udp) - 1;
vhdl_type *tmp_type = vhdl_type::std_logic_vector(msb, 0);
const vhdl_type *tmp_type = vhdl_type::std_logic_vector(msb, 0);
vhdl_signal_decl *tmp_decl = new vhdl_signal_decl(ss.str(), tmp_type);
arch->get_scope()->add_decl(tmp_decl);
@ -184,11 +184,11 @@ static void seq_udp_logic(vhdl_arch *arch, ivl_net_logic_t log)
ostringstream ss;
ss << "Generated from UDP " << ivl_udp_name(udp);
proc->set_comment(ss.str().c_str());
proc->set_comment(ss.str());
// Create a variable to hold the concatenation of the inputs
int msb = ivl_udp_nin(udp) - 1;
vhdl_type *tmp_type = vhdl_type::std_logic_vector(msb, 0);
const vhdl_type *tmp_type = vhdl_type::std_logic_vector(msb, 0);
proc->get_scope()->add_decl(new vhdl_var_decl("UDP_Inputs", tmp_type));
// Concatenate the inputs into a single expression that can be

View File

@ -1,7 +1,7 @@
/*
* VHDL code generation for LPM devices.
*
* Copyright (C) 2008-2009 Nick Gasson (nick@nickg.me.uk)
* Copyright (C) 2008-2025 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
@ -44,7 +44,7 @@ static vhdl_expr *part_select_base(vhdl_scope *scope, ivl_lpm_t lpm)
static vhdl_expr *binop_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm, vhdl_binop_t op)
{
unsigned out_width = ivl_lpm_width(lpm);
vhdl_type *result_type =
const vhdl_type *result_type =
vhdl_type::type_for(out_width, ivl_lpm_signed(lpm) != 0);
vhdl_binop_expr *expr = new vhdl_binop_expr(op, result_type);
@ -219,7 +219,7 @@ static vhdl_expr *shift_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm,
vhdl_type integer(VHDL_TYPE_INTEGER);
vhdl_expr *r_cast = rhs->cast(&integer);
vhdl_type *rtype = new vhdl_type(*lhs->get_type());
const vhdl_type *rtype = new vhdl_type(*lhs->get_type());
return new vhdl_binop_expr(lhs, shift_op, r_cast, rtype);
}

View File

@ -1,7 +1,7 @@
/*
* VHDL code generation for scopes.
*
* Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* Copyright (C) 2008-2025 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
@ -60,7 +60,7 @@ struct nexus_private_t {
/*
* Returns the scope_nexus_t of this nexus visible within scope.
*/
static scope_nexus_t *visible_nexus(nexus_private_t *priv, vhdl_scope *scope)
static scope_nexus_t *visible_nexus(nexus_private_t *priv, const vhdl_scope *scope)
{
list<scope_nexus_t>::iterator it;
for (it = priv->signals.begin(); it != priv->signals.end(); ++it) {
@ -109,7 +109,7 @@ static void link_scope_to_nexus_tmp(nexus_private_t *priv, vhdl_scope *scope,
/*
* Finds the name of the nexus signal within this scope.
*/
static string visible_nexus_signal_name(nexus_private_t *priv, vhdl_scope *scope,
static string visible_nexus_signal_name(nexus_private_t *priv, const vhdl_scope *scope,
unsigned *pin)
{
scope_nexus_t *sn = visible_nexus(priv, scope);
@ -201,7 +201,7 @@ void draw_nexus(ivl_nexus_t nexus)
}
else {
// Create a temporary signal to connect it to the nexus
vhdl_type *type =
const vhdl_type *type =
vhdl_type::type_for(ivl_logic_width(log), false);
ostringstream ss;
@ -238,8 +238,8 @@ void draw_nexus(ivl_nexus_t nexus)
else
lpm_temp_width = ivl_lpm_width(lpm);
vhdl_type *type = vhdl_type::type_for(lpm_temp_width,
ivl_lpm_signed(lpm) != 0);
const vhdl_type *type = vhdl_type::type_for(lpm_temp_width,
ivl_lpm_signed(lpm) != 0);
ostringstream ss;
ss << "LPM";
if (nexus == ivl_lpm_q(lpm))
@ -352,8 +352,8 @@ vhdl_var_ref *nexus_to_var_ref(vhdl_scope *scope, ivl_nexus_t nexus)
vhdl_decl *decl = scope->get_decl(renamed);
assert(decl);
vhdl_type *type = new vhdl_type(*(decl->get_type()));
vhdl_var_ref *ref = new vhdl_var_ref(renamed.c_str(), type);
const vhdl_type *type = new vhdl_type(*(decl->get_type()));
vhdl_var_ref *ref = new vhdl_var_ref(renamed, type);
if (decl->get_type()->get_name() == VHDL_TYPE_ARRAY)
ref->set_slice(new vhdl_const_int(pin), 0);
@ -478,7 +478,7 @@ string make_safe_name(ivl_signal_t sig)
// Check if `name' differs from an existing name only in case and
// make it unique if it does.
static void avoid_name_collision(string& name, vhdl_scope* scope)
static void avoid_name_collision(string& name, const vhdl_scope* scope)
{
if (scope->name_collides(name)) {
name += "_";
@ -542,7 +542,7 @@ static void declare_one_signal(vhdl_entity *ent, ivl_signal_t sig,
rename_signal(sig, name);
vhdl_type *sig_type;
const vhdl_type *sig_type;
unsigned dimensions = ivl_signal_dimensions(sig);
if (dimensions > 0) {
// Arrays are implemented by generating a separate type
@ -561,7 +561,7 @@ static void declare_one_signal(vhdl_entity *ent, ivl_signal_t sig,
int lsb = ivl_signal_array_base(sig);
int msb = lsb + ivl_signal_array_count(sig) - 1;
vhdl_type *array_type =
const vhdl_type *array_type =
vhdl_type::array_of(base_type, type_name, msb, lsb);
vhdl_decl *array_decl = new vhdl_type_decl(type_name, array_type);
ent->get_arch()->get_scope()->add_decl(array_decl);
@ -590,7 +590,7 @@ static void declare_one_signal(vhdl_entity *ent, ivl_signal_t sig,
ss << "Declared at " << ivl_signal_file(sig) << ":"
<< ivl_signal_lineno(sig);
}
decl->set_comment(ss.str().c_str());
decl->set_comment(ss.str());
ent->get_arch()->get_scope()->add_decl(decl);
}
@ -616,7 +616,7 @@ static void declare_one_signal(vhdl_entity *ent, ivl_signal_t sig,
newname += "_Reg";
rename_signal(sig, newname);
vhdl_type *reg_type = new vhdl_type(*sig_type);
const vhdl_type *reg_type = new vhdl_type(*sig_type);
ent->get_arch()->get_scope()->add_decl
(new vhdl_signal_decl(newname, reg_type));
@ -624,8 +624,8 @@ static void declare_one_signal(vhdl_entity *ent, ivl_signal_t sig,
// connect the register to the output
ent->get_arch()->add_stmt
(new vhdl_cassign_stmt
(new vhdl_var_ref(name.c_str(), NULL),
new vhdl_var_ref(newname.c_str(), NULL)));
(new vhdl_var_ref(name, NULL),
new vhdl_var_ref(newname, NULL)));
}
break;
case IVL_SIP_INOUT:
@ -678,7 +678,7 @@ static void declare_lpm(vhdl_arch *arch, ivl_scope_t scope)
* Map two signals together in an instantiation.
* The signals are joined by a nexus.
*/
static void map_signal(ivl_signal_t to, vhdl_entity *parent,
static void map_signal(ivl_signal_t to, const vhdl_entity *parent,
vhdl_comp_inst *inst)
{
// TODO: Work for multiple words
@ -704,7 +704,7 @@ static void map_signal(ivl_signal_t to, vhdl_entity *parent,
// However, Verilog allows the signal to be read in the parent.
// The solution used here is to create an intermediate signal
// and connect it to both ports.
vhdl_decl* from_decl =
const vhdl_decl* from_decl =
parent->get_arch()->get_scope()->get_decl(ref->get_name());
if (!from_decl->is_readable()
&& !arch_scope->have_declared(name + "_Readable")) {
@ -738,7 +738,7 @@ static void map_signal(ivl_signal_t to, vhdl_entity *parent,
/*
* Find all the port mappings of a module instantiation.
*/
static void port_map(ivl_scope_t scope, vhdl_entity *parent,
static void port_map(ivl_scope_t scope, const vhdl_entity *parent,
vhdl_comp_inst *inst)
{
// Find all the port mappings
@ -796,7 +796,7 @@ static int draw_function(ivl_scope_t scope, ivl_scope_t parent)
for (int i = 0; i < nports; i++) {
ivl_signal_t sig = ivl_scope_port(scope, i);
vhdl_type *sigtype =
const vhdl_type *sigtype =
vhdl_type::type_for(ivl_signal_width(sig),
ivl_signal_signed(sig) != 0);
@ -828,7 +828,7 @@ static int draw_function(ivl_scope_t scope, ivl_scope_t parent)
ivl_signal_t sig = ivl_scope_sig(scope, i);
if (ivl_signal_port(sig) == IVL_SIP_NONE) {
vhdl_type *sigtype =
const vhdl_type *sigtype =
vhdl_type::type_for(
ivl_signal_width(sig),
ivl_signal_signed(sig) != 0);
@ -859,7 +859,7 @@ static int draw_function(ivl_scope_t scope, ivl_scope_t parent)
ostringstream ss;
ss << "Generated from function " << funcname << " at "
<< ivl_scope_def_file(scope) << ":" << ivl_scope_def_lineno(scope);
func->set_comment(ss.str().c_str());
func->set_comment(ss.str());
ent->get_arch()->get_scope()->add_decl(func);
return 0;
@ -882,7 +882,7 @@ static int draw_task(ivl_scope_t scope, ivl_scope_t parent)
int nsigs = ivl_scope_sigs(scope);
for (int i = 0; i < nsigs; i++) {
ivl_signal_t sig = ivl_scope_sig(scope, i);
vhdl_type *sigtype =
const vhdl_type *sigtype =
vhdl_type::type_for(ivl_signal_width(sig),
ivl_signal_signed(sig) != 0);
@ -899,7 +899,7 @@ static int draw_task(ivl_scope_t scope, ivl_scope_t parent)
ostringstream ss;
ss << "Declared at " << ivl_signal_file(sig) << ":"
<< ivl_signal_lineno(sig) << " (in task " << taskname << ")";
decl->set_comment(ss.str().c_str());
decl->set_comment(ss.str());
ent->get_arch()->get_scope()->add_decl(decl);
@ -1110,10 +1110,10 @@ extern "C" int draw_constant_drivers(ivl_scope_t scope, void *)
for (list<ivl_signal_t>::const_iterator it = sn->connect.begin();
it != sn->connect.end();
++it) {
vhdl_type* rtype =
const vhdl_type* rtype =
vhdl_type::type_for(ivl_signal_width(sn->sig),
ivl_signal_signed(sn->sig));
vhdl_type* ltype =
const vhdl_type* ltype =
vhdl_type::type_for(ivl_signal_width(*it),
ivl_signal_signed(*it));
@ -1179,7 +1179,7 @@ extern "C" int draw_hierarchy(ivl_scope_t scope, void *_parent)
assert(parent_arch != NULL);
// Create a forward declaration for it
vhdl_scope *parent_scope = parent_arch->get_scope();
const vhdl_scope *parent_scope = parent_arch->get_scope();
if (!parent_scope->have_declared(ent->get_name())) {
vhdl_decl *comp_decl = vhdl_component_decl::component_decl_for(ent);
parent_arch->get_scope()->add_decl(comp_decl);
@ -1227,7 +1227,7 @@ extern "C" int draw_hierarchy(ivl_scope_t scope, void *_parent)
ostringstream ss;
ss << "Generated from instantiation at "
<< ivl_scope_file(scope) << ":" << ivl_scope_lineno(scope);
inst->set_comment(ss.str().c_str());
inst->set_comment(ss.str());
parent_arch->add_stmt(inst);
}

View File

@ -1,7 +1,7 @@
/*
* VHDL code generation for statements.
*
* Copyright (C) 2008-2023 Nick Gasson (nick@nickg.me.uk)
* Copyright (C) 2008-2025 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
@ -212,8 +212,8 @@ static int draw_block(vhdl_procedural *proc, stmt_container *container,
ivl_signal_t sig = ivl_scope_sig(block_scope, i);
remember_signal(sig, proc->get_scope());
vhdl_type* type = vhdl_type::type_for(ivl_signal_width(sig),
ivl_signal_signed(sig));
const vhdl_type* type = vhdl_type::type_for(ivl_signal_width(sig),
ivl_signal_signed(sig));
proc->get_scope()->add_decl
(new vhdl_var_decl(make_safe_name(sig), type));
}
@ -284,7 +284,7 @@ static vhdl_var_ref *make_assign_lhs(ivl_lval_t lval, vhdl_scope *scope)
decl = shadow_decl;
}
vhdl_type *ltype = new vhdl_type(*decl->get_type());
const vhdl_type *ltype = new vhdl_type(*decl->get_type());
vhdl_var_ref *lval_ref = new vhdl_var_ref(decl->get_name(), ltype);
if (base) {
if (decl->get_type()->get_name() == VHDL_TYPE_ARRAY)
@ -384,7 +384,7 @@ static void emit_wait_for_0(vhdl_procedural *proc,
need_wait_for_0 = true;
}
stmt_container::stmt_list_t &stmts = container->get_stmts();
const stmt_container::stmt_list_t &stmts = container->get_stmts();
bool last_was_wait =
!stmts.empty() && dynamic_cast<vhdl_wait_stmt*>(stmts.back());
@ -577,7 +577,7 @@ void make_assignment(vhdl_procedural *proc, stmt_container *container,
// Find the declaration of the LHS so we know what type
// of assignment statement to generate (is it a signal,
// a variable, etc?)
vhdl_decl *decl = proc->get_scope()->get_decl((*it)->get_name());
const vhdl_decl *decl = proc->get_scope()->get_decl((*it)->get_name());
assign_type = decl->assignment_type();
if (!check_valid_assignment(decl->assignment_type(), proc, stmt))
@ -1060,7 +1060,7 @@ static vhdl_var_ref *draw_case_test(vhdl_procedural *proc, stmt_container *conta
// variable to hold the result of the expression evaluation
if (typeid(*test) != typeid(vhdl_var_ref)) {
const char *tmp_name = "Verilog_Case_Ex";
vhdl_type *test_type = new vhdl_type(*test->get_type());
const vhdl_type *test_type = new vhdl_type(*test->get_type());
if (!proc->get_scope()->have_declared(tmp_name)) {
proc->get_scope()->add_decl
@ -1199,7 +1199,7 @@ static long get_number_as_long(ivl_expr_t expr)
* Build a check against a constant 'x'. This is for an out of range
* or undefined select.
*/
static void check_against_x(vhdl_binop_expr *all, vhdl_var_ref *test,
static void check_against_x(vhdl_binop_expr *all, const vhdl_var_ref *test,
ivl_expr_t expr, unsigned width, unsigned base,
bool is_casez)
{
@ -1208,7 +1208,7 @@ static void check_against_x(vhdl_binop_expr *all, vhdl_var_ref *test,
for (unsigned i = 0; i < ivl_expr_width(expr); i++) {
vhdl_binop_expr *sub_expr =
new vhdl_binop_expr(VHDL_BINOP_OR, vhdl_type::boolean());
vhdl_type *type;
const vhdl_type *type;
vhdl_var_ref *ref;
// Check if the test bit is 'z'.
@ -1241,7 +1241,7 @@ static void check_against_x(vhdl_binop_expr *all, vhdl_var_ref *test,
/*
* Build the test signal to constant bits check.
*/
static void process_number(vhdl_binop_expr *all, vhdl_var_ref *test,
static void process_number(vhdl_binop_expr *all, const vhdl_var_ref *test,
ivl_expr_t expr, unsigned width, unsigned base,
bool is_casez)
{
@ -1260,7 +1260,7 @@ static void process_number(vhdl_binop_expr *all, vhdl_var_ref *test,
vhdl_binop_expr *sub_expr =
new vhdl_binop_expr(VHDL_BINOP_OR, vhdl_type::boolean());
vhdl_type *type;
const vhdl_type *type;
vhdl_var_ref *ref;
// Check if the test bit is 'z'.
@ -1306,7 +1306,7 @@ static void process_number(vhdl_binop_expr *all, vhdl_var_ref *test,
/*
* Build the test signal to label signal check.
*/
static bool process_signal(vhdl_binop_expr *all, vhdl_var_ref *test,
static bool process_signal(vhdl_binop_expr *all, const vhdl_var_ref *test,
ivl_expr_t expr, unsigned width, unsigned base,
bool is_casez, unsigned swid, long sbase)
{
@ -1331,7 +1331,7 @@ static bool process_signal(vhdl_binop_expr *all, vhdl_var_ref *test,
for (unsigned i = 0; i < swid; i++) {
// Generate a comparison for this bit position
vhdl_binop_expr *cmp;
vhdl_type *type;
const vhdl_type *type;
vhdl_var_ref *ref;
// Check if this is an out of bounds access. If this is a casez

View File

@ -1,7 +1,7 @@
/*
* VHDL abstract syntax elements.
*
* Copyright (C) 2008-2013 Nick Gasson (nick@nickg.me.uk)
* Copyright (C) 2008-2025 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
@ -203,12 +203,12 @@ void vhdl_arch::emit(std::ostream &of, int level) const
blank_line(of, level); // Extra blank line after architectures;
}
void vhdl_procedural::add_blocking_target(vhdl_var_ref* ref)
void vhdl_procedural::add_blocking_target(const vhdl_var_ref* ref)
{
blocking_targets_.insert(ref->get_name());
}
bool vhdl_procedural::is_blocking_target(vhdl_var_ref* ref) const
bool vhdl_procedural::is_blocking_target(const vhdl_var_ref* ref) const
{
return blocking_targets_.find(ref->get_name()) != blocking_targets_.end();
}

View File

@ -1,7 +1,7 @@
/*
* VHDL abstract syntax elements.
*
* Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk)
* Copyright (C) 2008-2025 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
@ -141,7 +141,7 @@ enum vhdl_unaryop_t {
class vhdl_unaryop_expr : public vhdl_expr {
public:
vhdl_unaryop_expr(vhdl_unaryop_t op, vhdl_expr *operand,
vhdl_type *type)
const vhdl_type *type)
: vhdl_expr(type), op_(op), operand_(operand) {}
~vhdl_unaryop_expr();
@ -158,7 +158,7 @@ private:
*/
class vhdl_bit_spec_expr : public vhdl_expr {
public:
vhdl_bit_spec_expr(vhdl_type *type, vhdl_expr *others)
vhdl_bit_spec_expr(const vhdl_type *type, vhdl_expr *others)
: vhdl_expr(type), others_(others) {}
~vhdl_bit_spec_expr();
@ -608,7 +608,7 @@ public:
const std::string &get_name() const { return name_; }
const vhdl_type *get_type() const;
void set_type(vhdl_type *t) { type_ = t; }
void set_type(const vhdl_type *t) { type_ = t; }
void set_initial(vhdl_expr *initial);
bool has_initial() const { return has_initial_; }
@ -699,7 +699,7 @@ public:
*/
class vhdl_param_decl : public vhdl_decl {
public:
vhdl_param_decl(const char *name, vhdl_type *type)
vhdl_param_decl(const char *name, const vhdl_type *type)
: vhdl_decl(name, type) {}
void emit(std::ostream &of, int level) const;
assign_type_t assignment_type() const { return ASSIGN_CONST; }
@ -719,7 +719,7 @@ enum vhdl_port_mode_t {
*/
class vhdl_port_decl : public vhdl_decl {
public:
vhdl_port_decl(const char *name, vhdl_type *type,
vhdl_port_decl(const char *name, const vhdl_type *type,
vhdl_port_mode_t mode)
: vhdl_decl(name, type), mode_(mode) {}
@ -817,8 +817,8 @@ public:
bool contains_wait_stmt() const { return contains_wait_stmt_; }
// Managing set of blocking assignment targets in this block
void add_blocking_target(vhdl_var_ref* ref);
bool is_blocking_target(vhdl_var_ref* ref) const;
void add_blocking_target(const vhdl_var_ref* ref);
bool is_blocking_target(const vhdl_var_ref* ref) const;
protected:
stmt_container stmts_;

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2011-2012 Cary R. (cygcary@yahoo.com)
# Copyright (C) 2011-2025 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
@ -57,6 +57,8 @@ distclean: clean
cppcheck: $(O:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2022 Cary R. (cygcary@yahoo.com)
* Copyright (C) 2011-2025 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
@ -844,7 +844,7 @@ void emit_scope_call_path(ivl_scope_t scope, ivl_scope_t call_scope)
if (mod_scope != call_mod_scope) {
emit_scope_piece(mod_scope, call_mod_scope);
} else if (scope != call_scope) {
} else {
ivl_scope_t parent;
/* We only emit a scope path if the scope is a parent of the
* call scope. */

View File

@ -65,6 +65,8 @@ distclean: clean
cppcheck: $(O:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Stephen Williams (steve@icarus.com)
* Copyright (c) 2016-2025 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
@ -26,7 +26,7 @@
/*
* This function draws a BUFT to drive a constant delay value.
*/
static char* draw_const_net(void*ptr, char*suffix, uint64_t value)
static char* draw_const_net(const void*ptr, const char*suffix, uint64_t value)
{
char tmp[64];
char c4_value[69];
@ -52,7 +52,7 @@ static char* draw_const_net(void*ptr, char*suffix, uint64_t value)
/*
* Draw the appropriate delay statement.
*/
void draw_delay(void*ptr, unsigned wid, const char*input, ivl_expr_t rise_exp,
void draw_delay(const void*ptr, unsigned wid, const char*input, ivl_expr_t rise_exp,
ivl_expr_t fall_exp, ivl_expr_t decay_exp)
{
char tmp[64];

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 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
@ -334,7 +334,7 @@ static char* draw_net_input_drive(const ivl_nexus_t nex, ivl_nexus_ptr_t nptr)
char *result = 0;
ivl_expr_t d_rise, d_fall, d_decay;
unsigned dly_width = 0;
char *dly;
const char *dly;
/* Constants should have exactly 1 pin, with a literal value. */
assert(nptr_pin == 0);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2020 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 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
@ -196,7 +196,7 @@ uint64_t get_number_immediate64(ivl_expr_t expr)
return imm;
}
void eval_logic_into_integer(ivl_expr_t expr, unsigned ix)
static void eval_logic_into_integer(ivl_expr_t expr, unsigned ix)
{
switch (ivl_expr_type(expr)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2020 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 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
@ -24,7 +24,7 @@
void darray_new(ivl_type_t element_type, unsigned size_reg)
{
int wid;
char*signed_char;
const char*signed_char;
ivl_variable_type_t type = ivl_type_base(element_type);
if ((type == IVL_VT_BOOL) || (type == IVL_VT_LOGIC)) {

View File

@ -239,7 +239,7 @@ extern void draw_immediate_vec4(ivl_expr_t expr, const char*opcode);
/*
* Draw a delay statement.
*/
extern void draw_delay(void*ptr, unsigned wid, const char*input,
extern void draw_delay(const void*ptr, unsigned wid, const char*input,
ivl_expr_t rise_exp, ivl_expr_t fall_exp,
ivl_expr_t decay_exp);

View File

@ -46,7 +46,7 @@ const char *vvp_mangle_id(const char *id)
const char nosym[] = "!\"#%&'()*+,-/:;<=>?@[\\]^`{|}~";
char *se = strpbrk(inp, nosym);
const char *se = strpbrk(inp, nosym);
if (!se)
return id;
@ -95,7 +95,7 @@ const char *vvp_mangle_name(const char *id)
const char nosym[] = "\"\\";
char *se = strpbrk(inp, nosym);
const char *se = strpbrk(inp, nosym);
if (!se)
return id;
@ -1792,7 +1792,7 @@ static void draw_lpm_ff(ivl_lpm_t net)
assert(ivl_lpm_sync_set(net) == 0);
unsigned width = ivl_lpm_width(net);
char*edge = ivl_lpm_negedge(net) ? "n" : "p";
const char*edge = ivl_lpm_negedge(net) ? "n" : "p";
nex = ivl_lpm_clk(net);
assert(nex);

View File

@ -86,6 +86,8 @@ distclean: clean
cppcheck: $(O:.o=.cc)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
-UYY_USER_INIT \
-UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \
-UYYTYPE_INT8 -UYYTYPE_INT16 -UYYTYPE_UINT8 -UYYTYPE_UINT16 \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -104,7 +104,7 @@ int Entity::elaborate_ports_(void)
for (std::vector<InterfacePort*>::const_iterator cur = ports_.begin()
; cur != ports_.end() ; ++cur) {
InterfacePort*cur_port = *cur;
const InterfacePort*cur_port = *cur;
const VType*type = cur_port->type;
if (type == 0) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 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
@ -72,7 +72,7 @@ int Entity::emit(ostream&out)
; cur != ports_.end() ; ++cur) {
InterfacePort*port = *cur;
VType::decl_t&decl = declarations_[port->name];
const VType::decl_t&decl = declarations_[port->name];
if (sep) out << sep << endl;
else sep = ", ";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012-2015 / Stephen Williams (steve@icarus.com),
* Copyright CERN 2016
* @author Maciej Suminski (maciej.suminski@cern.ch)
@ -276,7 +276,7 @@ ExpAggregate::choice_t::choice_t(ExpRange*rang)
ExpAggregate::choice_t::choice_t(const choice_t&other)
{
if(Expression*e = other.expr_.get())
if(const Expression*e = other.expr_.get())
expr_.reset(e->clone());
if(other.range_.get())

View File

@ -1,7 +1,7 @@
#ifndef IVL_expression_H
#define IVL_expression_H
/*
* Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2015 / Stephen Williams (steve@icarus.com),
* Copyright CERN 2016
* @author Maciej Suminski (maciej.suminski@cern.ch)
@ -724,7 +724,7 @@ class ExpName : public Expression {
public: // Base methods
Expression*clone() const;
int elaborate_lval(Entity*ent, ScopeBase*scope, bool);
int elaborate_rval(Entity*ent, ScopeBase*scope, const InterfacePort*);
int elaborate_rval(const Entity*ent, const ScopeBase*scope, const InterfacePort*);
const VType* probe_type(Entity*ent, ScopeBase*scope) const;
const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
@ -841,7 +841,7 @@ class ExpScopedName : public Expression {
int elaborate_lval(Entity*ent, ScopeBase*scope, bool is_sequ)
{ return name_->elaborate_lval(ent, get_scope(scope), is_sequ); }
int elaborate_rval(Entity*ent, ScopeBase*scope, const InterfacePort*lval)
int elaborate_rval(const Entity*ent, const ScopeBase*scope, const InterfacePort*lval)
{ return name_->elaborate_rval(ent, get_scope(scope), lval); }
const VType* probe_type(Entity*ent, ScopeBase*scope) const

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
* Copyright CERN 2016
* @author Maciej Suminski (maciej.suminski@cern.ch)
@ -275,7 +275,7 @@ int ExpName::elaborate_lval(Entity*ent, ScopeBase*scope, bool is_sequ)
return errors;
}
int ExpName::elaborate_rval(Entity*ent, ScopeBase*scope, const InterfacePort*lval)
int ExpName::elaborate_rval(const Entity*ent, const ScopeBase*scope, const InterfacePort*lval)
{
int errors = 0;
@ -466,7 +466,7 @@ int ExpAggregate::elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VType
// each parsed element may be bound to multiple choices, so
// account for that.
for (size_t edx = 0 ; edx < elements_.size() ; edx += 1) {
element_t*ecur = elements_[edx];
const element_t*ecur = elements_[edx];
if (ecur->count_choices() == 0)
choice_count += 1;
else
@ -867,7 +867,7 @@ int ExpFunc::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*)
// SystemVerilog functions work only with defined size data types, therefore
// if header does not specify argument or return type size, create a function
// instance that work with this particular size.
if(def_ && !def_->is_std() && def_->unbounded()) {
if(!def_->is_std() && def_->unbounded()) {
def_ = def_->make_instance(argv_, scope);
name_ = def_->name(); // TODO necessary?
}
@ -1013,10 +1013,10 @@ const VType* ExpName::probe_type(Entity*ent, ScopeBase*scope) const
}
if(scope) {
if (Signal*sig = scope->find_signal(name_))
if (const Signal*sig = scope->find_signal(name_))
return sig->peek_type();
if (Variable*var = scope->find_variable(name_))
if (const Variable*var = scope->find_variable(name_))
return var->peek_type();
const VType*type = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012-2015 / Stephen Williams (steve@icarus.com)
* @author Maciej Suminski (maciej.suminski@cern.ch)
*
@ -828,7 +828,7 @@ bool ExpName::check_const_record_workaround_(const VTypeRecord*rec,
for(vector<VTypeRecord::element_t*>::const_reverse_iterator it = elements.rbegin();
it != elements.rend(); ++it) {
VTypeRecord::element_t* el = (*it);
const VTypeRecord::element_t* el = (*it);
if(el->peek_name() == name_) {
const VType*type = el->peek_type();

View File

@ -6,7 +6,7 @@
%{
/*
* Copyright (c) 2011-2017 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 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
@ -53,10 +53,10 @@ extern int lexor_keyword_code (const char*str, unsigned len);
#define yylloc (*yyllocp)
#define yylval (*yylvalp)
static bool are_underscores_correct(char* text);
static bool is_based_correct(char* text);
static char* escape_quot_and_dup(char* text);
static char* escape_apostrophe_and_dup(char* text);
static bool are_underscores_correct(const char* text);
static bool is_based_correct(const char* text);
static char* escape_quot_and_dup(const char* text);
static char* escape_apostrophe_and_dup(const char* text);
static double make_double_from_based(char* text);
static int64_t make_long_from_based(char* text);
@ -220,7 +220,7 @@ extern void yyparse_set_filepath(const char*path);
* \return true is returned if underscores are placed
* correctly according to specification
*/
static bool are_underscores_correct(char* text)
static bool are_underscores_correct(const char* text)
{
unsigned char underscore_allowed = 0;
const char* cp;
@ -253,12 +253,12 @@ static bool is_char_ok(char c, int base)
* \return true is returned if a based number
* is formed well according to specification
*/
static bool is_based_correct(char* text)
static bool is_based_correct(const char* text)
{
char* ptr;
const char* ptr;
//BASE examination
char clean_base[4] = {0,};
char* clean_base_end = clean_base + sizeof(clean_base);
const char* clean_base_end = clean_base + sizeof(clean_base);
char* clean_base_ptr = clean_base;
for(ptr = text; ptr != strchr(text, '#'); ++ptr)
{
@ -336,7 +336,7 @@ static bool is_based_correct(char* text)
*
* \return pointer to the new string is returned
*/
static char* escape_quot_and_dup(char* text)
static char* escape_quot_and_dup(const char* text)
{
char* newstr = new char[strlen(text)+1];
@ -377,7 +377,7 @@ static char* escape_quot_and_dup(char* text)
*
* \return pointer to the new string is returned
*/
static char* escape_apostrophe_and_dup(char* text)
static char* escape_apostrophe_and_dup(const char* text)
{
char* newstr = new char[2];
newstr[0] = text[1];
@ -629,7 +629,7 @@ static double make_double_from_based(char* text)
{
char* first_hash_ptr = strchr(text, '#');
char* second_hash_ptr = strrchr(text, '#');
char* last_char_ptr = strchr(text, '\0') - 1;
const char* last_char_ptr = strchr(text, '\0') - 1;
//put null byte in lieu of hashes
*first_hash_ptr = '\0';
*second_hash_ptr = '\0';
@ -638,7 +638,7 @@ static double make_double_from_based(char* text)
unsigned base = (unsigned)strtol(text, 0, 10) ;
double mantissa = 0.0;
char*ptr = first_hash_ptr + 1;
const char*ptr = first_hash_ptr + 1;
for( ; ptr != second_hash_ptr ; ++ptr)
{
if(*ptr == '.')
@ -699,12 +699,12 @@ static unsigned short short_from_hex_char(char ch)
static int64_t make_long_from_based(char* text) {
char* first_hash_ptr = strchr(text, '#');
char* second_hash_ptr = strrchr(text, '#');
char* end_ptr = strrchr(text, '\0');
const char* end_ptr = strrchr(text, '\0');
//now lets deduce the base
*first_hash_ptr = '\0';
unsigned base = (unsigned)strtol(text, 0, 10) ;
char *ptr = first_hash_ptr + 1;
const char *ptr = first_hash_ptr + 1;
int64_t mantissa = 0;
for( ; ptr != second_hash_ptr ; ++ptr)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
* Copyright CERN 2016
* @author Maciej Suminski <maciej.suminski@cern.ch>
@ -114,7 +114,7 @@ static void import_ieee(void);
static void import_ieee_use(const YYLTYPE&loc, ActiveScope*res, perm_string package, perm_string name);
static void import_std_use(const YYLTYPE&loc, ActiveScope*res, perm_string package, perm_string name);
static void dump_library_package(ostream&file, perm_string lname, perm_string pname, Package*pack)
static void dump_library_package(ostream&file, perm_string lname, perm_string pname, const Package*pack)
{
file << "package " << lname << "." << pname << endl;
if (pack) {

View File

@ -6,7 +6,7 @@
%parse-param {perm_string parse_library_name}
%{
/*
* Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012-2016 / Stephen Williams (steve@icarus.com),
* @author Maciej Suminski (maciej.suminski@cern.ch)
*
@ -68,7 +68,7 @@ inline void FILE_NAME(LineInfo*tmp, const struct yyltype&where)
(Current).first_line = (Rhs)[1].first_line; \
(Current).text = file_path; /*(Rhs)[1].text;*/ } while (0)
static void yyerror(YYLTYPE*yyllocp,yyscan_t yyscanner,const char*file_path,bool, const char*msg);
static void yyerror(const YYLTYPE*yyllocp,yyscan_t yyscanner,const char*file_path,bool, const char*msg);
int parse_errors = 0;
int parse_sorrys = 0;
@ -758,7 +758,7 @@ component_specification
composite_type_definition
/* constrained_array_definition */
: K_array index_constraint K_of subtype_indication
{ VTypeArray*tmp = new VTypeArray($4, $2);
{ const VTypeArray*tmp = new VTypeArray($4, $2);
delete $2;
$$ = tmp;
}
@ -770,7 +770,7 @@ composite_type_definition
ExpRange*tmp = new ExpRange(NULL, NULL, ExpRange::DOWNTO);
r.push_back(tmp);
FILE_NAME(tmp, @1);
VTypeArray*arr = new VTypeArray($6, &r);
const VTypeArray*arr = new VTypeArray($6, &r);
$$ = arr;
}
@ -2218,7 +2218,7 @@ range_list
record_type_definition
: K_record element_declaration_list K_end K_record
{ VTypeRecord*tmp = new VTypeRecord($2);
{ const VTypeRecord*tmp = new VTypeRecord($2);
$$ = tmp;
}
;
@ -2787,7 +2787,7 @@ type_declaration
type_definition
: '(' enumeration_literal_list ')'
{ VTypeEnum*tmp = new VTypeEnum($2);
{ const VTypeEnum*tmp = new VTypeEnum($2);
active_scope->use_enum(tmp);
delete $2;
$$ = tmp;
@ -2935,7 +2935,7 @@ K_postponed_opt : K_postponed | ;
K_shared_opt : K_shared | ;
%%
static void yyerror(YYLTYPE*loc, yyscan_t, const char*, bool, const char*msg)
static void yyerror(const YYLTYPE*loc, yyscan_t, const char*, bool, const char*msg)
{
fprintf(stderr, "%s:%u: %s\n", loc->text, loc->first_line, msg);
parse_errors += 1;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011,2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -58,7 +58,7 @@ void bind_architecture_to_entity(const char*ename, Architecture*arch)
/* FIXME: entities can have multiple architectures attached to them
This is to be configured by VHDL's configurations (not yet implemented) */
Architecture*old_arch = idx->second->add_architecture(arch);
const Architecture*old_arch = idx->second->add_architecture(arch);
if (old_arch != arch) {
cerr << arch->get_fileline() << ": warning: "
<< "Architecture " << arch->get_name()

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 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
@ -187,7 +187,7 @@ int ProcedureCall::elaborate(Entity*ent, ScopeBase*scope)
if(param_list_) {
for(list<named_expr_t*>::iterator it = param_list_->begin();
it != param_list_->end(); ++it) {
named_expr_t* e = *it;
const named_expr_t* e = *it;
arg_types.push_back(e->expr()->probe_type(ent, scope));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2013-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
* Copyright CERN 2015
* @author Maciej Suminski (maciej.suminski@cern.ch)
@ -290,13 +290,13 @@ struct check_return_type : public SeqStmtVisitor {
void operator() (SequentialStmt*s)
{
ReturnStmt*ret;
const ReturnStmt*ret;
if((ret = dynamic_cast<ReturnStmt*>(s))) {
const Expression*expr = ret->peek_expr();
const VType*t = NULL;
if(const ExpName*n = dynamic_cast<const ExpName*>(expr)) {
if(Variable*v = subp_->find_variable(n->peek_name()))
if(const Variable*v = subp_->find_variable(n->peek_name()))
t = v->peek_type();
} else {
t = expr->peek_type();

View File

@ -104,6 +104,8 @@ distclean: clean
# an explicit value (i.e. the define is expected to be real code).
cppcheck: $(O:.o=.c) $(OPP:.o=.cc) $(M:.o=.c) $(V:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
-UYY_USER_INIT -UYY_LOCATION_PRINT -Uyyset_out -Uyyset_lineno \
-Uyyset_in -Uyyset_extra -Uyyset_debug -Uyylex_destroy \

View File

@ -573,7 +573,7 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus,
if (width == -1) width = 0;
{
char *cp = vpi_get_str(vpiFullName, info->scope);
const char *cp = vpi_get_str(vpiFullName, info->scope);
/* If the default buffer is too small, make it big enough. */
size = strlen(cp) + 1;
if ((signed)size < (width+1)) size = width+1;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 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
@ -126,7 +126,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) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2025 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
@ -61,7 +61,7 @@ struct vcd_info_chunk {
struct vcd_info_chunk*info_chunk_list = 0;
struct vcd_info*new_vcd_info(void)
static struct vcd_info*new_vcd_info(void)
{
struct vcd_info_chunk*cur_chunk = info_chunk_list;
if (cur_chunk == 0 || cur_chunk->chunk_fill == 0xffff) {
@ -77,7 +77,7 @@ struct vcd_info*new_vcd_info(void)
return ptr;
}
void functor_all_vcd_info( void (*fun) (struct vcd_info*info) )
static void functor_all_vcd_info( void (*fun) (struct vcd_info*info) )
{
struct vcd_info_chunk*cur;
for (cur = info_chunk_list ; cur ; cur = cur->chunk_next) {
@ -88,7 +88,7 @@ void functor_all_vcd_info( void (*fun) (struct vcd_info*info) )
}
}
void delete_all_vcd_info(void)
static void delete_all_vcd_info(void)
{
while (info_chunk_list) {
struct vcd_info_chunk*tmp = info_chunk_list->chunk_next;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 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
@ -230,7 +230,8 @@ static PLI_INT32 sys_value_plusargs_calltf(ICARUS_VPI_CONST PLI_BYTE8*name)
/* Look for a +arg that matches the prefix supplied. */
for (idx = 0 ; idx < info.argc ; idx += 1) {
char*sp, *tp, *end;
char*sp, *end;
const char*tp;
size_t sp_len;
/* Skip arguments that are not +args. */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007-2023 Stephen Williams (steve@icarus.com)
* Copyright (c) 2007-2025 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
@ -146,7 +146,7 @@ static const char*edge_str(int vpi_edge)
return "edge.. ";
}
vpiHandle get_port_handle(char* port_name, const int sdf_lineno)
static vpiHandle get_port_handle(char* port_name, const int sdf_lineno)
{
vpiHandle scope = sdf_cur_cell;
@ -176,7 +176,7 @@ vpiHandle get_port_handle(char* port_name, const int sdf_lineno)
vpiHandle port_handle = NULL;
while ((port=vpi_scan(port_i)) != NULL) {
char *port_name_ = vpi_get_str(vpiName, port) ;
const char *port_name_ = vpi_get_str(vpiName, port) ;
if (strcmp(port_name_, token) == 0) {
if (port_handle != NULL) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2021 Cary R. (cygcary@yahoo.com)
* Copyright (C) 2008-2025 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
@ -217,7 +217,7 @@ static PLI_INT32 simparam_str_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name_ext)
retval = strdup("N/A"); /* Nothing for now. */
} else if (strcmp(param, "cwd") == 0) {
char path [MAX_STRING_RESULT];
char *ptr = getcwd(path, MAX_STRING_RESULT);
const char *ptr = getcwd(path, MAX_STRING_RESULT);
if (ptr == NULL) {
strcpy(path, "<error getting the cwd, is it too long?>");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2025 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
@ -51,7 +51,7 @@ int is_escaped_id(const char *name)
return 1;
}
int vcd_instance_contains_dumpable_items(int dumpable_types[], vpiHandle item)
int vcd_instance_contains_dumpable_items(const int dumpable_types[], vpiHandle item)
{
int i;
for (i = 0; dumpable_types[i] > 0; i++) {
@ -101,7 +101,7 @@ static int vcd_names_compare(const void *s1, const void *s2)
return strcmp(v1, v2);
}
const char *vcd_names_search(struct vcd_names_list_s*tab, const char *key)
const char *vcd_names_search(const struct vcd_names_list_s*tab, const char *key)
{
const char **v;

View File

@ -1,7 +1,7 @@
#ifndef IVL_vcd_priv_H
#define IVL_vcd_priv_H
/*
* Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2025 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
@ -29,7 +29,7 @@
EXTERN int is_escaped_id(const char *name);
EXTERN int vcd_instance_contains_dumpable_items(int dumpable_types[], vpiHandle item);
EXTERN int vcd_instance_contains_dumpable_items(const int dumpable_types[], vpiHandle item);
struct vcd_names_s;
EXTERN struct stringheap_s name_heap;
@ -42,7 +42,7 @@ struct vcd_names_list_s {
EXTERN void vcd_names_add(struct vcd_names_list_s*tab, const char *name);
EXTERN const char *vcd_names_search(struct vcd_names_list_s*tab,
EXTERN const char *vcd_names_search(const struct vcd_names_list_s*tab,
const char *key);
EXTERN void vcd_names_sort(struct vcd_names_list_s*tab);