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"