diff --git a/lib/checkother.cpp b/lib/checkother.cpp index a402424b1..96d1d1719 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3195,7 +3195,8 @@ void CheckOther::sizeofCalculation() sizeofCalculationError(tok2, tok2->isExpandedMacro()); break; } - } + } else if (tok2->type() == Token::eIncDecOp) + sizeofCalculationError(tok2, tok2->isExpandedMacro()); } } } diff --git a/test/testother.cpp b/test/testother.cpp index fc1b3c8fa..acd5c8a11 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1428,6 +1428,12 @@ private: check("sizeof(void * const)"); ASSERT_EQUALS("", errout.str()); + + check("sizeof(foo++)"); + ASSERT_EQUALS("[test.cpp:1]: (warning) Found calculation inside sizeof().\n", errout.str()); + + check("sizeof(--foo)"); + ASSERT_EQUALS("[test.cpp:1]: (warning) Found calculation inside sizeof().\n", errout.str()); } void switchRedundantAssignmentTest() {