Fixed #8271 (FP uninitMemberVar: Handle method call in middle of statement)
This commit is contained in:
parent
31a1cebc5f
commit
526d8b76a6
|
@ -573,11 +573,6 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
|||
assignVar(ftok->next()->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;
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue