From b914cda1c7949c1252179208b402d554d7aa1158 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 28 Jun 2025 12:29:41 -0400 Subject: [PATCH] Internals: cppcheck cleanups. No functional change. --- Makefile.in | 8 ++++--- include/verilated.cpp | 20 +++++++----------- include/verilated_random.h | 25 +++++++++++----------- include/verilated_threads.cpp | 39 ++++++++++++++++++----------------- include/verilated_threads.h | 1 + include/verilated_vpi.cpp | 2 +- src/V3Assert.cpp | 1 + src/V3AstNodes.cpp | 2 ++ src/V3Delayed.cpp | 2 ++ src/V3Dfg.cpp | 1 + src/V3DfgAstToDfg.cpp | 4 ++++ src/V3DfgPasses.cpp | 8 +++---- src/V3DfgPeephole.cpp | 10 ++++----- src/V3EmitCBase.cpp | 2 +- src/V3EmitMk.cpp | 2 +- src/V3Error.cpp | 10 +++++---- src/V3ParseImp.cpp | 4 ++-- src/V3SchedTiming.cpp | 1 + src/V3String.cpp | 2 +- src/V3Task.cpp | 12 +++++------ 20 files changed, 85 insertions(+), 71 deletions(-) diff --git a/Makefile.in b/Makefile.in index f3f22f548..f22aec998 100644 --- a/Makefile.in +++ b/Makefile.in @@ -411,10 +411,12 @@ CHECK_YL = $(wildcard \ $(srcdir)/src/*.l ) CPPCHECK = src/cppcheck_filtered cppcheck CPPCHECK_FLAGS = --enable=all --inline-suppr \ - --suppress=cstyleCast --suppress=useInitializationList \ - --suppress=nullPointer --suppress=nullPointerRedundantCheck --suppress=ctunullpointer \ + --suppress=cstyleCast --suppress=ctunullpointer \ + --suppress=derefInvalidIteratorRedundantCheck \ + --suppress=nullPointer --suppress=nullPointerRedundantCheck \ + --suppress=templateRecursion \ --suppress=unusedFunction --suppress=unusedScopedObject \ - --suppress=useStlAlgorithm \ + --suppress=useInitializationList --suppress=useStlAlgorithm \ CPPCHECK_FLAGS += --xml CPPCHECK_DEP = $(subst .cpp,.cppcheck,$(CHECK_CPP)) diff --git a/include/verilated.cpp b/include/verilated.cpp index eb59da7fa..f0a7f0630 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -411,7 +411,7 @@ IData VL_SCOPED_RAND_RESET_I(int obits, uint64_t scopeHash, uint64_t salt) VL_MT if (Verilated::threadContextp()->randReset() == 0) return 0; IData data = ~0; if (Verilated::threadContextp()->randReset() != 1) { // if 2, randomize - VlRNG rng(Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt); + VlRNG rng{Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt}; data = rng.rand64(); } data &= VL_MASK_I(obits); @@ -422,7 +422,7 @@ QData VL_SCOPED_RAND_RESET_Q(int obits, uint64_t scopeHash, uint64_t salt) VL_MT if (Verilated::threadContextp()->randReset() == 0) return 0; QData data = ~0ULL; if (Verilated::threadContextp()->randReset() != 1) { // if 2, randomize - VlRNG rng(Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt); + VlRNG rng{Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt}; data = rng.rand64(); } data &= VL_MASK_Q(obits); @@ -432,31 +432,27 @@ QData VL_SCOPED_RAND_RESET_Q(int obits, uint64_t scopeHash, uint64_t salt) VL_MT WDataOutP VL_SCOPED_RAND_RESET_W(int obits, WDataOutP outwp, uint64_t scopeHash, uint64_t salt) VL_MT_UNSAFE { if (Verilated::threadContextp()->randReset() != 2) { return VL_RAND_RESET_W(obits, outwp); } - VlRNG rng(Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt); + VlRNG rng{Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt}; for (int i = 0; i < VL_WORDS_I(obits) - 1; ++i) outwp[i] = rng.rand64(); outwp[VL_WORDS_I(obits) - 1] = rng.rand64() & VL_MASK_E(obits); return outwp; } IData VL_SCOPED_RAND_RESET_ASSIGN_I(int obits, uint64_t scopeHash, uint64_t salt) VL_MT_UNSAFE { - IData data = ~0; - VlRNG rng(Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt); - data = rng.rand64(); - data &= VL_MASK_I(obits); + VlRNG rng{Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt}; + const IData data = rng.rand64() & VL_MASK_I(obits); return data; } QData VL_SCOPED_RAND_RESET_ASSIGN_Q(int obits, uint64_t scopeHash, uint64_t salt) VL_MT_UNSAFE { - QData data = ~0ULL; - VlRNG rng(Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt); - data = rng.rand64(); - data &= VL_MASK_Q(obits); + VlRNG rng{Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt}; + const QData data = rng.rand64() & VL_MASK_Q(obits); return data; } WDataOutP VL_SCOPED_RAND_RESET_ASSIGN_W(int obits, WDataOutP outwp, uint64_t scopeHash, uint64_t salt) VL_MT_UNSAFE { - VlRNG rng(Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt); + VlRNG rng{Verilated::threadContextp()->randSeed() ^ scopeHash ^ salt}; for (int i = 0; i < VL_WORDS_I(obits) - 1; ++i) outwp[i] = rng.rand64(); outwp[VL_WORDS_I(obits) - 1] = rng.rand64() & VL_MASK_E(obits); return outwp; diff --git a/include/verilated_random.h b/include/verilated_random.h index fc08596db..f144b179d 100644 --- a/include/verilated_random.h +++ b/include/verilated_random.h @@ -409,7 +409,7 @@ public: // Record a flat (non-class) element into the array variable table template typename std::enable_if::value, void>::type - record_arr_table(T& var, const std::string name, int dimension, std::vector indices, + record_arr_table(T& var, const std::string& name, int dimension, std::vector indices, std::vector idxWidths) { const std::string key = generateKey(name, m_index); m_arr_vars[key] = std::make_shared(name, &var, m_index, indices, idxWidths); @@ -418,7 +418,7 @@ public: // Recursively record all elements in an unpacked array template - void record_arr_table(VlUnpacked& var, const std::string name, int dimension, + void record_arr_table(VlUnpacked& var, const std::string& name, int dimension, std::vector indices, std::vector idxWidths) { if ((dimension > 0) && (N_Depth != 0)) { idxWidths.push_back(32); @@ -434,7 +434,7 @@ public: // Recursively record all elements in a queue template - void record_arr_table(VlQueue& var, const std::string name, int dimension, + void record_arr_table(VlQueue& var, const std::string& name, int dimension, std::vector indices, std::vector idxWidths) { if ((dimension > 0) && (var.size() != 0)) { idxWidths.push_back(32); @@ -449,8 +449,9 @@ public: // Recursively record all elements in an associative array template - void record_arr_table(VlAssocArray& var, const std::string name, int dimension, - std::vector indices, std::vector idxWidths) { + void record_arr_table(VlAssocArray& var, const std::string& name, + int dimension, std::vector indices, + std::vector idxWidths) { if ((dimension > 0) && (var.size() != 0)) { for (auto it = var.begin(); it != var.end(); ++it) { const T_Key& key = it->first; @@ -478,7 +479,7 @@ public: // Register a single structArray element via write_var template typename std::enable_if::value, void>::type - record_struct_arr(T& var, const std::string name, int dimension, std::vector indices, + record_struct_arr(T& var, const std::string& name, int dimension, std::vector indices, std::vector idxWidths) { std::ostringstream oss; for (size_t i = 0; i < indices.size(); ++i) { @@ -492,7 +493,7 @@ public: // Recursively process VlUnpacked of structs template - void record_struct_arr(VlUnpacked& var, const std::string name, int dimension, + void record_struct_arr(VlUnpacked& var, const std::string& name, int dimension, std::vector indices, std::vector idxWidths) { if (dimension > 0 && N_Depth != 0) { constexpr size_t idx_width = 1 << VL_CLOG2_CE_Q(VL_CLOG2_CE_Q(N_Depth) + 1); @@ -507,7 +508,7 @@ public: // Recursively process VlQueue of structs template - void record_struct_arr(VlQueue& var, const std::string name, int dimension, + void record_struct_arr(VlQueue& var, const std::string& name, int dimension, std::vector indices, std::vector idxWidths) { if ((dimension > 0) && (var.size() != 0)) { idxWidths.push_back(32); @@ -521,9 +522,9 @@ public: // Recursively process associative arrays of structs template - void record_struct_arr(VlAssocArray& var, const std::string name, - int dimension, std::vector indices, - std::vector idxWidths) { + void record_struct_arr(VlAssocArray& var, const std::string& name, + int dimension, const std::vector& indices, + const std::vector& idxWidths) { if ((dimension > 0) && (!var.empty())) { for (auto it = var.begin(); it != var.end(); ++it) { const T_Key& key = it->first; @@ -551,7 +552,7 @@ public: // Helper: Register all members of a user-defined struct template - void modifyMembers(T& obj, std::index_sequence, std::string baseName) { + void modifyMembers(T& obj, std::index_sequence, const std::string& baseName) { // Use the indices to access each member via std::get (void)std::initializer_list{ (write_var(std::get(obj.getMembers(obj)), obj.memberWidth()[I], diff --git a/include/verilated_threads.cpp b/include/verilated_threads.cpp index 06c500bca..9c883b43a 100644 --- a/include/verilated_threads.cpp +++ b/include/verilated_threads.cpp @@ -135,7 +135,7 @@ bool VlThreadPool::isNumactlRunning() { } std::string VlThreadPool::numaAssign() { -#if defined(__linux) || defined(CPU_ZERO) // Linux-like; assume we have pthreads etc +#if defined(__linux) || defined(CPU_ZERO) || defined(VL_CPPCHECK) // Linux-like pthreads // If not under numactl, make a reasonable processor affinity selection if (isNumactlRunning()) return "running under numactl"; // User presumably set affinity const int num_threads = static_cast(m_workers.size()); @@ -157,24 +157,25 @@ std::string VlThreadPool::numaAssign() { std::map processor_core; std::multimap core_processors; std::set cores; - int processor = -1; - int core = -1; - while (!is.eof()) { - std::string line; - std::getline(is, line); - static std::string::size_type pos = line.find(":"); - int number = -1; - if (pos != std::string::npos) number = atoi(line.c_str() + pos + 1); - if (line.compare(0, std::strlen("processor"), "processor") == 0) { - processor = number; - core = -1; - } else if (line.compare(0, std::strlen("core id"), "core id") == 0) { - core = number; - // std::cout << "p" << processor << " socket " << socket << " c" << core << std::endl; - cores.emplace(core); - processor_core[processor] = core; - core_processors.emplace(core, processor); - unassigned_processors.push_back(processor); + { + int processor = -1; + while (!is.eof()) { + std::string line; + std::getline(is, line); + static std::string::size_type pos = line.find(":"); + int number = -1; + if (pos != std::string::npos) number = atoi(line.c_str() + pos + 1); + if (line.compare(0, std::strlen("processor"), "processor") == 0) { + processor = number; + } else if (line.compare(0, std::strlen("core id"), "core id") == 0) { + const int core = number; + // std::cout << "p" << processor << " socket " << socket << " c" << core << + // std::endl; + cores.emplace(core); + processor_core[processor] = core; + core_processors.emplace(core, processor); + unassigned_processors.push_back(processor); + } } } diff --git a/include/verilated_threads.h b/include/verilated_threads.h index c2f05a480..643ebcf0b 100644 --- a/include/verilated_threads.h +++ b/include/verilated_threads.h @@ -241,6 +241,7 @@ public: private: VL_UNCOPYABLE(VlThreadPool); + // cppcheck-suppress unusedPrivateFunction static bool isNumactlRunning(); std::string numaAssign(); }; diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 5af4bc916..a244b9e48 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -2537,6 +2537,7 @@ void vl_vpi_put_word_gen(const VerilatedVpioVar* vop, T word, size_t bitCount, s = (info.m_datap[info.m_wordOffset + 1] & ~info.m_maskHi) | ((word >> (wordBits - info.m_bitOffset)) & info.m_maskHi); } + // cppcheck-has-bug-suppress unreadVariable info.m_datap[info.m_wordOffset] = (info.m_datap[info.m_wordOffset] & ~info.m_maskLo) | ((word << info.m_bitOffset) & info.m_maskLo); } @@ -2978,7 +2979,6 @@ void vl_get_value_array_vectors(unsigned index, const unsigned num, const unsign p_vpi_vecval dst) { static_assert(std::is_unsigned::value, "type T is not unsigned"); // ensure logical right shift - const unsigned element_size_bytes = VL_BYTES_I(packedSize); const unsigned element_size_words = VL_WORDS_I(packedSize); if (sizeof(T) == sizeof(QData)) { for (unsigned i = 0; i < num; ++i) { diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index d62f01066..83ccfcc5c 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -53,6 +53,7 @@ class AssertVisitor final : public VNVisitor { // METHODS static AstNodeExpr* assertOnCond(FileLine* fl, VAssertType type, VAssertDirectiveType directiveType) { + // cppcheck-suppress missingReturn switch (directiveType) { case VAssertDirectiveType::INTRINSIC: return new AstConst{fl, AstConst::BitTrue{}}; case VAssertDirectiveType::VIOLATION_CASE: { diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 59bed182c..c94976487 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -3072,7 +3072,9 @@ void AstCMethodHard::setPurity() { return; } auto isPureIt = isPureMethod.find(name()); + // cppcheck-suppress derefInvalidIteratorRedundantCheck UASSERT_OBJ(isPureIt != isPureMethod.end(), this, "Unknown purity of method " + name()); + // cppcheck-suppress derefInvalidIteratorRedundantCheck m_pure = isPureIt->second; if (!m_pure) return; if (!fromp()->isPure()) m_pure = false; diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 0ff531812..e8c8e5203 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -167,6 +167,8 @@ class DelayedVisitor final : public VNVisitor { } m_kitUnion; public: + VarScopeInfo() = default; + ~VarScopeInfo() = default; // Accessors for the above union fields auto& shadowVariableKit() { UASSERT(m_scheme == Scheme::ShadowVar, "Inconsistent Scheme"); diff --git a/src/V3Dfg.cpp b/src/V3Dfg.cpp index 65b9e4da4..7d6dede3d 100644 --- a/src/V3Dfg.cpp +++ b/src/V3Dfg.cpp @@ -443,6 +443,7 @@ DfgVarPacked* DfgVertex::getResultVar() { // Inspect existing variables fully written by this vertex, and choose one DfgVarPacked* resp = nullptr; + // cppcheck-has-bug-suppress constParameter this->forEachSink([&resp](DfgVertex& sink) { DfgVarPacked* const varp = sink.cast(); if (!varp) return; diff --git a/src/V3DfgAstToDfg.cpp b/src/V3DfgAstToDfg.cpp index e02a14e3f..7773d46ce 100644 --- a/src/V3DfgAstToDfg.cpp +++ b/src/V3DfgAstToDfg.cpp @@ -165,6 +165,7 @@ class AstToDfgVisitor final : public VNVisitor { if (AstVarRef* const vrefp = VN_CAST(nodep, VarRef)) { m_foundUnhandled = false; visit(vrefp); + // cppcheck-has-bug-suppress knownConditionTrueFalse if (m_foundUnhandled) return false; getVertex(vrefp)->as()->addDriver(flp, 0, vtxp); return true; @@ -178,6 +179,7 @@ class AstToDfgVisitor final : public VNVisitor { } m_foundUnhandled = false; visit(vrefp); + // cppcheck-has-bug-suppress knownConditionTrueFalse if (m_foundUnhandled) return false; getVertex(vrefp)->as()->addDriver(flp, lsbp->toUInt(), vtxp); return true; @@ -191,6 +193,7 @@ class AstToDfgVisitor final : public VNVisitor { } m_foundUnhandled = false; visit(vrefp); + // cppcheck-has-bug-suppress knownConditionTrueFalse if (m_foundUnhandled) return false; getVertex(vrefp)->as()->addDriver(flp, idxp->toUInt(), vtxp); return true; @@ -244,6 +247,7 @@ class AstToDfgVisitor final : public VNVisitor { m_foundUnhandled = false; iterate(rhsp); + // cppcheck-has-bug-suppress knownConditionTrueFalse if (m_foundUnhandled) { revertUncommittedVertices(); markReferenced(nodep); diff --git a/src/V3DfgPasses.cpp b/src/V3DfgPasses.cpp index 1408fe40d..19a226f4a 100644 --- a/src/V3DfgPasses.cpp +++ b/src/V3DfgPasses.cpp @@ -447,17 +447,17 @@ void V3DfgPasses::binToOneHot(DfgGraph& dfg, V3DfgBinToOneHotContext& ctx) { const uint32_t val = pair.first; const std::vector& terms = pair.second; // Create the ArraySel - FileLine* const flp = terms.front().m_vtxp->fileline(); - DfgArraySel* const aselp = new DfgArraySel{dfg, flp, bitDTypep}; + FileLine* const aflp = terms.front().m_vtxp->fileline(); + DfgArraySel* const aselp = new DfgArraySel{dfg, aflp, bitDTypep}; aselp->fromp(tabVtxp); - aselp->bitp(new DfgConst{dfg, flp, width, val}); + aselp->bitp(new DfgConst{dfg, aflp, width, val}); // The inverted value, if needed DfgNot* notp = nullptr; // Repalce the terms for (const Term& term : terms) { if (term.m_inv) { if (!notp) { - notp = new DfgNot{dfg, flp, bitDTypep}; + notp = new DfgNot{dfg, aflp, bitDTypep}; notp->srcp(aselp); } term.m_vtxp->replaceWith(notp); diff --git a/src/V3DfgPeephole.cpp b/src/V3DfgPeephole.cpp index ead99f657..5056e45b6 100644 --- a/src/V3DfgPeephole.cpp +++ b/src/V3DfgPeephole.cpp @@ -345,14 +345,14 @@ class V3DfgPeephole final : public DfgVisitor { // Make associative trees right leaning to reduce pattern variations, and for better CSE bool changed = false; while (true) { - Vertex* const lhsp = vtxp->lhsp()->template cast(); - if (!lhsp || lhsp->hasMultipleSinks()) break; + Vertex* const alhsp = vtxp->lhsp()->template cast(); + if (!alhsp || alhsp->hasMultipleSinks()) break; APPLYING(RIGHT_LEANING_ASSOC) { // Rotate the expression tree rooted at 'vtxp' to the right, producing a // right-leaning tree - DfgVertex* const ap = lhsp->lhsp(); - DfgVertex* const bp = lhsp->rhsp(); + DfgVertex* const ap = alhsp->lhsp(); + DfgVertex* const bp = alhsp->rhsp(); DfgVertex* const cp = vtxp->rhsp(); AstNodeDType* const rootDtyptp = vtxp->dtypep(); @@ -364,7 +364,7 @@ class V3DfgPeephole final : public DfgVisitor { } Vertex* const childp = make(vtxp->fileline(), childDtyptp, bp, cp); - Vertex* const rootp = make(lhsp->fileline(), rootDtyptp, ap, childp); + Vertex* const rootp = make(alhsp->fileline(), rootDtyptp, ap, childp); replace(vtxp, rootp); changed = true; vtxp = rootp; diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index 5f8b81e66..a84980080 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -278,7 +278,7 @@ void EmitCBaseVisitorConst::emitVarAccessors(const AstVar* nodep) { void EmitCBaseVisitorConst::emitModCUse(const AstNodeModule* modp, VUseType useType) { bool nl = false; - forModCUse(modp, useType, [&](string entry) { + forModCUse(modp, useType, [&](const string& entry) { puts(entry); nl = true; }); diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 1c5d2983f..9b8a61c58 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -78,7 +78,7 @@ private: std::vector m_concatenableListsByDescSize; // Lists sorted by size, descending EmitGroup(std::vector inputFiles, uint64_t totalScore, - std::string groupFilePrefix) + const std::string& groupFilePrefix) : m_inputFiles{std::move(inputFiles)} , m_totalScore{totalScore} , m_groupFilePrefix{groupFilePrefix} {} diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 3688e9355..0ef6e50fb 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -172,10 +172,12 @@ void V3ErrorGuarded::v3errorEndGuts(std::ostringstream& sstr, const string& extr // If suppressed print only first line to reduce verbosity string firstLine = msg; - string::size_type pos; - if ((pos = firstLine.find('\n')) != string::npos) { - firstLine.erase(pos, firstLine.length() - pos); - firstLine += "..."; + { + string::size_type pos; + if ((pos = firstLine.find('\n')) != string::npos) { + firstLine.erase(pos, firstLine.length() - pos); + firstLine += "..."; + } } if (m_errorSuppressed) msg = firstLine; // Suppress duplicate messages diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index e50935548..f1ba202b6 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -552,8 +552,8 @@ int V3ParseImp::tokenPipelineId(int token) { VL_RESTORER(yylval); // Remember value, as about to read ahead if (m_tokenLastBison.token != '@' && m_tokenLastBison.token != '#' && m_tokenLastBison.token != '.') { - if (const size_t depth = tokenPipeScanIdInst(0)) return yaID__aINST; - if (const size_t depth = tokenPipeScanIdType(0)) return yaID__aTYPE; + if (tokenPipeScanIdInst(0)) return yaID__aINST; + if (tokenPipeScanIdType(0)) return yaID__aTYPE; } if (nexttok == '#') { // e.g. class_type parameter_value_assignment '::' const size_t depth = tokenPipeScanParam(0, false); diff --git a/src/V3SchedTiming.cpp b/src/V3SchedTiming.cpp index 97d2a827d..b0dbda05f 100644 --- a/src/V3SchedTiming.cpp +++ b/src/V3SchedTiming.cpp @@ -342,6 +342,7 @@ void transformForks(AstNetlist* const netlistp) { m_funcp = nodep; m_awaitMoved = false; iterateChildren(nodep); + // cppcheck-has-bug-suppress knownConditionTrueFalse if (nodep->isCoroutine() && m_awaitMoved && !nodep->stmtsp()->exists([](AstCAwait*) { return true; })) { // co_return at the end (either that or a co_await is required in a coroutine diff --git a/src/V3String.cpp b/src/V3String.cpp index ba0fcbfc7..4176e9b07 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -204,7 +204,7 @@ string VString::unquoteSVString(const string& text, string& errOut) { } else if (*cp == '\\') { if (octal_digits) { newtext += octal_val; - octal_digits = 0; + // below: octal_digits = 0; octal_val = 0; } quoted = true; diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 54a810f2d..d569ad780 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -451,12 +451,12 @@ class TaskVisitor final : public VNVisitor { AstNodeExpr* postRhsp = new AstVarRef{newvscp->fileline(), newvscp, VAccess::READ}; if (AstResizeLValue* soutPinp = VN_CAST(outPinp, ResizeLValue)) { outPinp = soutPinp->lhsp(); - if (AstNodeUniop* soutPinp = VN_CAST(outPinp, Extend)) { - outPinp = soutPinp->lhsp(); - } else if (AstNodeUniop* soutPinp = VN_CAST(outPinp, ExtendS)) { - outPinp = soutPinp->lhsp(); - } else if (AstSel* soutPinp = VN_CAST(outPinp, Sel)) { - outPinp = soutPinp->fromp(); + if (AstNodeUniop* aoutPinp = VN_CAST(outPinp, Extend)) { + outPinp = aoutPinp->lhsp(); + } else if (AstNodeUniop* aoutPinp = VN_CAST(outPinp, ExtendS)) { + outPinp = aoutPinp->lhsp(); + } else if (AstSel* aoutPinp = VN_CAST(outPinp, Sel)) { + outPinp = aoutPinp->fromp(); } else { outPinp->v3fatalSrc("Inout pin resizing should have had extend or select"); }