From 3a310f19f0d2b3949fc1e1ae06e4ed27283398da Mon Sep 17 00:00:00 2001 From: Krzysztof Bieganski Date: Wed, 25 May 2022 12:59:21 +0200 Subject: [PATCH] Adjust loop conditions in VlTriggerVec functions This change is not a functional one; it is only meant to appease the compiler with respect to warnings such as GCC's `-Wtype-limits`. Signed-off-by: Krzysztof Bieganski --- include/verilated_types.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/verilated_types.h b/include/verilated_types.h index 47a231570..47cd12d9b 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -76,6 +76,7 @@ extern std::string VL_TO_STRING_W(int words, const WDataInP obj); template // class VlTriggerVec final { + // TODO: static assert T_size > 0, and don't generate when empty private: // MEMBERS std::array m_flags; // State of the assoc array @@ -95,19 +96,19 @@ public: // Return true iff at least one element is set bool any() const { - for (size_t i = 0; i < T_size; ++i) + for (size_t i = 0; i < m_flags.size(); ++i) if (m_flags[i]) return true; return false; } // Set all elements true in 'this' that are set in 'other' void set(const VlTriggerVec& other) { - for (size_t i = 0; i < T_size; ++i) m_flags[i] |= other.m_flags[i]; + for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] |= other.m_flags[i]; } // Set elements of 'this' to 'a & !b' element-wise void andNot(const VlTriggerVec& a, const VlTriggerVec& b) { - for (size_t i = 0; i < T_size; ++i) m_flags[i] = a.m_flags[i] & !b.m_flags[i]; + for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] = a.m_flags[i] & !b.m_flags[i]; } };