From 0159287437467ebbf0eb014ea5a9ed88cabeca1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 31 Dec 2009 09:10:20 +0100 Subject: [PATCH] Fixed #1183 (False positive: uninitialized variable p 'd = bar(sizeof(*p));') --- lib/checkother.cpp | 7 +++++++ test/testother.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 8f99d0e54..cb93df782 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1628,6 +1628,13 @@ private: --parlevel; } + else if (Token::simpleMatch(tok2, "sizeof (")) + { + tok2 = tok2->link(); + if (!tok2) + break; + } + else if (tok2->varId()) { if (Token::Match(tok2->tokAt(-2), "[(,] *")) diff --git a/test/testother.cpp b/test/testother.cpp index b55675673..29176b765 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1302,6 +1302,13 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo()\n" + "{\n" + " Foo *p;\n" + " x = bar(sizeof(*p));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // arrays.. checkUninitVar("void f()\n" "{\n"