From aa2ad416299fb93f8e34555f1d9a23f0c35f2a3b Mon Sep 17 00:00:00 2001 From: PKEuS Date: Tue, 6 Nov 2012 11:39:47 -0800 Subject: [PATCH] Print message "Found calculation inside sizeof()" also for increment/decrement operator. --- lib/checkother.cpp | 3 ++- test/testother.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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() {