From b1635c21cc506a2e3062c38daf53957cd2755762 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 3 Aug 2026 00:25:42 -0700 Subject: [PATCH] Cleanup cppcheck --- cppcheck.sup | 20 ++++++++++---------- elaborate.cc | 17 +++++++++++------ parse.y | 2 +- tgt-vvp/cppcheck.sup | 4 ++-- vvp/cppcheck.sup | 18 +++++++++--------- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/cppcheck.sup b/cppcheck.sup index e4ec1d594..b9e6f7bc8 100644 --- a/cppcheck.sup +++ b/cppcheck.sup @@ -15,9 +15,9 @@ constVariablePointer:main.cc:425 constVariablePointer:main.cc:675 // const auto should be const -constVariablePointer:elab_expr.cc:566 -constVariablePointer:elab_expr.cc:569 -constVariablePointer:elab_expr.cc:638 +constVariablePointer:elab_expr.cc:628 +constVariablePointer:elab_expr.cc:631 +constVariablePointer:elab_expr.cc:700 // The reference cannot be const since it is updated in the calling function. constParameterReference:net_udp.cc:37 @@ -36,23 +36,23 @@ uninitMemberVar:t-dll.cc:41 uninitMemberVar:t-dll.cc:109 // By convention we put statics at the top scope. -variableScope:pform.cc:3632 +variableScope:pform.cc:3630 // These are correct and are used to find the base (zero) pin. -thisSubtraction:netlist.h:5376 -thisSubtraction:netlist.h:5385 +thisSubtraction:netlist.h:5370 +thisSubtraction:netlist.h:5379 // This is used when running a debugger // debugger_release knownConditionTrueFalse:main.cc:955 // These should be checked, but are not real issues -knownConditionTrueFalse:elaborate.cc:7970 +knownConditionTrueFalse:elaborate.cc:8165 knownConditionTrueFalse:elab_sig.cc:272 knownConditionTrueFalse:elab_sig.cc:345 // Yes, it's a duplicate -duplicateCondition:elaborate.cc:8190 +duplicateCondition:elaborate.cc:8216 // To complicated to use std::find_if() useStlAlgorithm:map_named_args.cc:38 @@ -732,9 +732,9 @@ unusedFunction:net_link.cc:283 // intersect() unusedFunction:net_link.cc:687 // get_def_fileline() -unusedFunction:net_scope.cc:201 +unusedFunction:net_scope.cc:200 // get_module_port_info() -unusedFunction:net_scope.cc:617 +unusedFunction:net_scope.cc:631 // find_link_signal() unusedFunction:netlist.cc:113 // find_link() diff --git a/elaborate.cc b/elaborate.cc index fad79f93b..a8cb2e388 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -2085,7 +2085,7 @@ void PGModule::elaborate_mod_(Design*des, const Module*rmod, NetScope*scope) con // We do not support automatic bits to real conversion // for inout ports. if ((sig->data_type() == IVL_VT_REAL ) && - !prts.empty() && (prts[0]->data_type() != IVL_VT_REAL )) { + (prts[0]->data_type() != IVL_VT_REAL )) { cerr << pins[idx]->get_fileline() << ": error: " << "Cannot automatically connect bit based " "inout port " << (idx+1) << " (" << port_name @@ -2096,7 +2096,7 @@ void PGModule::elaborate_mod_(Design*des, const Module*rmod, NetScope*scope) con } // We do not support real inout ports at all. - if (!prts.empty() && (prts[0]->data_type() == IVL_VT_REAL )) { + if (prts[0]->data_type() == IVL_VT_REAL ) { cerr << pins[idx]->get_fileline() << ": error: " << "No support for connecting real inout ports (" "port " << (idx+1) << " (" << port_name @@ -2150,7 +2150,7 @@ void PGModule::elaborate_mod_(Design*des, const Module*rmod, NetScope*scope) con // width cast. Since a real is only one bit the whole // thing needs to go to each instance when arrayed. if ((sig->data_type() != IVL_VT_REAL ) && - !prts.empty() && (prts[0]->data_type() == IVL_VT_REAL )) { + (prts[0]->data_type() == IVL_VT_REAL )) { if (sig->vector_width() % instance.size() != 0) { cerr << pins[idx]->get_fileline() << ": error: " "When automatically converting a real " @@ -2175,7 +2175,7 @@ void PGModule::elaborate_mod_(Design*des, const Module*rmod, NetScope*scope) con // If we have a bit/vector port driving a single real // signal then we convert the value to a real. if ((sig->data_type() == IVL_VT_REAL ) && - !prts.empty() && (prts[0]->data_type() != IVL_VT_REAL )) { + (prts[0]->data_type() != IVL_VT_REAL )) { prts_vector_width -= prts[0]->vector_width() - 1; prts[0] = cast_to_real(des, scope, prts[0]); // No support for multiple real drivers. @@ -2193,7 +2193,7 @@ void PGModule::elaborate_mod_(Design*des, const Module*rmod, NetScope*scope) con // If we have a 4-state bit/vector port driving a // 2-state signal then we convert the value to 2-state. if ((sig->data_type() == IVL_VT_BOOL ) && - !prts.empty() && (prts[0]->data_type() == IVL_VT_LOGIC )) { + (prts[0]->data_type() == IVL_VT_LOGIC )) { for (unsigned pidx = 0; pidx < prts.size(); pidx += 1) { prts[pidx] = cast_to_int2(des, scope, prts[pidx], prts[pidx]->vector_width()); @@ -2203,7 +2203,7 @@ void PGModule::elaborate_mod_(Design*des, const Module*rmod, NetScope*scope) con // A real to real connection is not allowed for arrayed // instances. You cannot have multiple real drivers. if ((sig->data_type() == IVL_VT_REAL ) && - !prts.empty() && (prts[0]->data_type() == IVL_VT_REAL ) && + (prts[0]->data_type() == IVL_VT_REAL ) && instance.size() != 1) { cerr << pins[idx]->get_fileline() << ": error: " << "An arrayed instance of " << rmod->mod_name() @@ -4689,6 +4689,11 @@ NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope, << peek_tail_name(path_) << "' is not allowed." << endl; des->errors++; } + } else { + cerr << get_fileline() << ": error: trying to generate a call to '" + << peek_tail_name(path_) << "' which is not a task of function." << endl; + des->errors++; + return nullptr; } /* The caller has checked the parms_ size to make sure it diff --git a/parse.y b/parse.y index 98c313c64..52ed19ad2 100644 --- a/parse.y +++ b/parse.y @@ -627,7 +627,7 @@ static char *pform_start_block_with_labels( static PBlock *pform_finish_block(const YYLTYPE&block_loc, const YYLTYPE&end_loc, const char *type, - char *raw_name, char *end_label, + char *raw_name, const char *end_label, PBlock::BL_TYPE block_type, procedural_item_list_t *raw_items) { diff --git a/tgt-vvp/cppcheck.sup b/tgt-vvp/cppcheck.sup index 0e1b39881..674eeff04 100644 --- a/tgt-vvp/cppcheck.sup +++ b/tgt-vvp/cppcheck.sup @@ -28,8 +28,8 @@ nullPointerOutOfMemory:modpath.c:139 // calloc @ 138 nullPointerOutOfMemory:modpath.c:140 // calloc @ 138 nullPointerOutOfMemory:modpath.c:141 // calloc @ 138 nullPointerOutOfMemory:modpath.c:142 // calloc @ 138 -nullPointerOutOfMemory:vvp_process.c:2218 // malloc @ 2216 -nullPointerOutOfMemory:vvp_process.c:2219 // malloc @ 2216 +nullPointerOutOfMemory:vvp_process.c:2290 // malloc @ 2288 +nullPointerOutOfMemory:vvp_process.c:2291 // malloc @ 2288 nullPointerOutOfMemory:vvp_scope.c:876 // calloc @ 865 nullPointerOutOfMemory:vvp_scope.c:900 // calloc @ 865 nullPointerOutOfMemory:vvp_scope.c:1094 // calloc @ 1092 diff --git a/vvp/cppcheck.sup b/vvp/cppcheck.sup index 84e457bc1..55777e056 100644 --- a/vvp/cppcheck.sup +++ b/vvp/cppcheck.sup @@ -78,7 +78,7 @@ duplInheritedMember:symbols.h:112 duplicateValueTernary:class_type.cc:268 // cppcheck is wrong this can be true or false -knownConditionTrueFalse:vthread.cc:3625 +knownConditionTrueFalse:vthread.cc:3823 knownConditionTrueFalse:vpi_priv.cc:681 knownConditionTrueFalse:vpi_priv.cc:2030 @@ -92,7 +92,7 @@ knownConditionTrueFalse:vthread.cc:3571 duplicateExpression:vpi_signal.cc:1207 // cppcheck does not relize this is deleted[] in the called routine -leakNoVarFunctionCall:compile.cc:508 +leakNoVarFunctionCall:compile.cc:522 // Yes, these are not currently initialized in the constructor // All are added after __vpiSysTaskCall is built @@ -151,13 +151,13 @@ knownConditionTrueFalse:vpi_modules.cc:118 redundantAssignment:vpi_modules.cc:117 // cppcheck does not undestand the format types match -invalidScanfArgType_int:compile.cc:653 -invalidScanfArgType_int:compile.cc:659 -invalidScanfArgType_int:compile.cc:665 -invalidScanfArgType_int:vthread.cc:4634 -invalidScanfArgType_int:vthread.cc:4637 -invalidScanfArgType_int:vthread.cc:4640 -invalidScanfArgType_int:vthread.cc:4643 +invalidScanfArgType_int:compile.cc:667 +invalidScanfArgType_int:compile.cc:673 +invalidScanfArgType_int:compile.cc:679 +invalidScanfArgType_int:vthread.cc:4832 +invalidScanfArgType_int:vthread.cc:4835 +invalidScanfArgType_int:vthread.cc:4838 +invalidScanfArgType_int:vthread.cc:4841 // The new() operator is always used to allocate space for this class and // pool is defined there.