From 29e74222fb2ef16823548fa926f57b06baa736f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 26 Dec 2013 13:41:21 +0100 Subject: [PATCH] Sizeof calculation: Fixed FP for sizeof(int*[2]) --- lib/checksizeof.cpp | 3 +++ test/testsizeof.cpp | 3 +++ 2 files changed, 6 insertions(+) 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());