diff --git a/lib/checksizeof.cpp b/lib/checksizeof.cpp index 214b60abf..de8d9309e 100644 --- a/lib/checksizeof.cpp +++ b/lib/checksizeof.cpp @@ -233,6 +233,9 @@ static bool isCalculation(const Token *op) if (!op->astOperand2()) return false; + if (op->astOperand2()->str() == "[") + return false; + // type specification? std::stack operands; operands.push(op); diff --git a/test/testsizeof.cpp b/test/testsizeof.cpp index 42acb4aaa..f13b6fe71 100644 --- a/test/testsizeof.cpp +++ b/test/testsizeof.cpp @@ -97,6 +97,9 @@ private: check("sizeof(void * const)"); ASSERT_EQUALS("", errout.str()); + check("sizeof(int*[2])"); + ASSERT_EQUALS("", errout.str()); + check("sizeof(foo++)"); ASSERT_EQUALS("[test.cpp:1]: (warning) Found calculation inside sizeof().\n", errout.str());