From 526d8b76a6b3ffdd4dde3d74fc5da1726c89b6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 11 Nov 2017 21:28:24 +0100 Subject: [PATCH] Fixed #8271 (FP uninitMemberVar: Handle method call in middle of statement) --- lib/checkclass.cpp | 5 ----- test/testconstructors.cpp | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 25d9d1d9b..d300e547a 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -573,11 +573,6 @@ void CheckClass::initializeVarList(const Function &func, std::listnext()->varId(), scope, usage); } - // Before a new statement there is "[{};()=[]" or :: - // We can also have a new statement after any operators or comparisons - if (! Token::Match(ftok, "%op%|%comp%|{|}|;|(|)|=|[|::")) - continue; - // If assignment comes after an && or || this is really inconclusive because of short circuiting if (Token::Match(ftok, "%oror%|&&")) continue; diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 0c71a80dd..62af43bde 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -143,6 +143,7 @@ private: TEST_CASE(uninitVar28); // ticket #6258 TEST_CASE(uninitVar29); TEST_CASE(uninitVar30); // ticket #6417 + TEST_CASE(uninitVar31); // ticket #8271 TEST_CASE(uninitVarEnum); TEST_CASE(uninitVarStream); TEST_CASE(uninitVarTypedef); @@ -2327,6 +2328,24 @@ private: ASSERT_EQUALS("", errout.str()); } + void uninitVar31() { // ticket #8271 + check("void bar();\n" + "class MyClass {\n" + "public:\n" + " MyClass();\n" + " void Restart();\n" + "protected:\n" + " int m_retCode;\n" + "};\n" + "MyClass::MyClass() {\n" + " bar(),Restart();\n" + "}\n" + "void MyClass::Restart() {\n" + " m_retCode = 0;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void uninitVarArray1() { check("class John\n" "{\n"