diff --git a/examples/make_protect_lib/sim_main.cpp b/examples/make_protect_lib/sim_main.cpp index 03697a316..8c0933f37 100644 --- a/examples/make_protect_lib/sim_main.cpp +++ b/examples/make_protect_lib/sim_main.cpp @@ -17,7 +17,8 @@ #endif int main(int argc, char** argv) { - if (false && argc && argv) {} + (void)argc; + (void)argv; // Construct context to hold simulation time, etc const std::unique_ptr contextp{new VerilatedContext}; diff --git a/include/verilated.cpp b/include/verilated.cpp index 67fb673b9..c58a9fcc7 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -886,7 +886,7 @@ void _vl_vsformat(std::string& output, const std::string& format, va_list ap) VL case '^': { // Realtime const int lbits = va_arg(ap, int); const double d = va_arg(ap, double); - if (lbits) {} // UNUSED - always 64 + (void)lbits; // UNUSED - always 64 if (fmt == '^') { // Realtime if (!widthSet) width = Verilated::threadContextp()->impp()->timeFormatWidth(); const int timeunit = va_arg(ap, int); @@ -3101,7 +3101,7 @@ void Verilated::stackCheck(QData needSize) VL_MT_UNSAFE { haveSize / 1024, (needSize * 2) / 1024); } #else - if (false && needSize) {} // Unused argument + (void)needSize; // Unused argument #endif } diff --git a/src/V3Number.cpp b/src/V3Number.cpp index 31bb94c25..028ba5213 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -428,7 +428,7 @@ V3Number& V3Number::setLongS(int32_t value) { int32_t s; } u; u.s = value; - if (u.s) {} + (void)u.s; m_data.num()[0].m_value = u.u; opCleanThis(); return *this; @@ -441,7 +441,7 @@ V3Number& V3Number::setDouble(double value) { uint32_t u[2]; } u; u.d = value; - if (u.d != 0.0) {} + (void)u.d; for (int i = 2; i < words(); i++) m_data.num()[i] = {0, 0}; m_data.num()[0].m_value = u.u[0]; m_data.num()[1].m_value = u.u[1]; @@ -2374,7 +2374,7 @@ V3Number& V3Number::opRToIRoundS(const V3Number& lhs) { uint64_t q; } u; u.d = v; - if (u.d == 0.0) {} + (void)u.d; const int exp = static_cast((u.q >> 52ULL) & VL_MASK_Q(11)) - 1023; const int lsb = exp - 52; diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index faacf9a3b..893eb75ae 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -1691,7 +1691,7 @@ class TristateVisitor final : public TristateBaseVisitor { AstVar* const enVarp = getCreateEnVarp(nodep->varp()); nodep->user1p(new AstVarRef{nodep->fileline(), enVarp, VAccess::READ}); } - if (m_alhs) {} // NOP; user1() already passed down from assignment + (void)m_alhs; // NOP; user1() already passed down from assignment } } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index ee949abeb..64742726a 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -6265,7 +6265,7 @@ class WidthVisitor final : public VNVisitor { nodep->dtypeChgSigned(nodep->lhsp()->isSigned()); const AstNodeBiop* const newp = iterate_shift_final(nodep); VL_DANGLING(nodep); - if (newp) {} // Ununused + (void)newp; // Ununused } void iterate_shift_prelim(AstNodeBiop* nodep) { // Shifts @@ -6617,7 +6617,7 @@ class WidthVisitor final : public VNVisitor { AstNodeDType* const expDTypep = underp->findUInt32DType(); underp = iterateCheck(nodep, "file_descriptor", underp, SELF, FINAL, expDTypep, EXTEND_EXP); - if (underp) {} // cppcheck + (void)underp; // cppcheck } void iterateCheckSigned32(AstNode* nodep, const char* side, AstNode* underp, Stage stage) { // Coerce child to signed32 if not already. Child is self-determined @@ -6629,7 +6629,7 @@ class WidthVisitor final : public VNVisitor { AstNodeDType* const expDTypep = nodep->findSigned32DType(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); } - if (underp) {} // cppcheck + (void)underp; // cppcheck } void iterateCheckReal(AstNode* nodep, const char* side, AstNode* underp, Stage stage) { // Coerce child to real if not already. Child is self-determined @@ -6645,7 +6645,7 @@ class WidthVisitor final : public VNVisitor { AstNodeDType* const expDTypep = nodep->findDoubleDType(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); } - if (underp) {} // cppcheck + (void)underp; // cppcheck } void iterateCheckString(AstNode* nodep, const char* side, AstNode* underp, Stage stage) { if (stage & PRELIM) { @@ -6655,7 +6655,7 @@ class WidthVisitor final : public VNVisitor { AstNodeDType* const expDTypep = nodep->findStringDType(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); } - if (underp) {} // cppcheck + (void)underp; // cppcheck } void iterateCheckTyped(AstNode* nodep, const char* side, AstNode* underp, AstNodeDType* expDTypep, Stage stage) { @@ -6665,7 +6665,7 @@ class WidthVisitor final : public VNVisitor { if (stage & FINAL) { underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); } - if (underp) {} // cppcheck + (void)underp; // cppcheck } void iterateCheckSizedSelf(AstNode* nodep, const char* side, AstNode* underp, Determ determ, Stage stage) { @@ -6681,7 +6681,7 @@ class WidthVisitor final : public VNVisitor { underp = VN_IS(underp, NodeExpr) ? checkCvtUS(VN_AS(underp, NodeExpr)) : underp; AstNodeDType* const expDTypep = underp->dtypep(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); - if (underp) {} // cppcheck + (void)underp; // cppcheck } void iterateCheckAssign(AstNode* nodep, const char* side, AstNode* rhsp, Stage stage, AstNodeDType* lhsDTypep) { @@ -6727,7 +6727,7 @@ class WidthVisitor final : public VNVisitor { rhsp = iterateCheck(nodep, side, rhsp, ASSIGN, FINAL, lhsDTypep, lhsStream ? EXTEND_OFF : EXTEND_LHS); // if (debug()) nodep->dumpTree("- checkout: "); - if (rhsp) {} // cppcheck + (void)rhsp; // cppcheck } void iterateCheckBool(AstNode* nodep, const char* side, AstNode* underp, Stage stage) { diff --git a/test_regress/t/t_dpi_context_c.cpp b/test_regress/t/t_dpi_context_c.cpp index e21d79363..9025e9407 100644 --- a/test_regress/t/t_dpi_context_c.cpp +++ b/test_regress/t/t_dpi_context_c.cpp @@ -77,7 +77,7 @@ int dpic_line() { printf("%%Warning: svGetCallerInfo failed\n"); return 0; } - if (svGetCallerInfo(nullptr, nullptr)) {} // Check doesn't segflt + (void)svGetCallerInfo(nullptr, nullptr); // Check doesn't segflt return lineno; } @@ -115,7 +115,7 @@ int dpic_save(int value) { } vp.i = value; - if (vp.i) {} + (void)vp.i; if (svPutUserData(scope, &Dpic_Unique, vp.ptr)) { printf("%%Warning: svPutUserData failed\n"); return 0; diff --git a/test_regress/t/t_dpi_export_context2_bad.cpp b/test_regress/t/t_dpi_export_context2_bad.cpp index 4c4eeb82a..02d92ece2 100644 --- a/test_regress/t/t_dpi_export_context2_bad.cpp +++ b/test_regress/t/t_dpi_export_context2_bad.cpp @@ -35,11 +35,12 @@ int dpii_task() { // Check DPI warnings svScope scope = svGetScope(); // Will warn - if (scope) {} // Unused + (void)scope; // Unused const char* filenamep = ""; int lineno = 0; svGetCallerInfo(&filenamep, &lineno); // Will warn - if (filenamep && lineno) {} // Unused + (void)filenamep; // Unused + (void)lineno; // Unused dpix_task(); return 0; diff --git a/test_regress/t/t_dpi_open_elem_c.cpp b/test_regress/t/t_dpi_open_elem_c.cpp index 0af199d79..4df979b85 100644 --- a/test_regress/t/t_dpi_open_elem_c.cpp +++ b/test_regress/t/t_dpi_open_elem_c.cpp @@ -127,7 +127,7 @@ static void _dpii_logic_elem_ux(int p, int u, const svOpenArrayHandle i, const s #endif int sizeInputOfArray = svSizeOfArray(i); // svSizeOfArray(i) undeterministic as not in C representation - if (sizeInputOfArray) {} + (void)sizeInputOfArray; // unused for (int a = svLow(i, 1); a <= svHigh(i, 1); ++a) { if (dim == 1) {