Skip to content

Commit 526d8b7

Browse files
committed
Fixed danmar#8271 (FP uninitMemberVar: Handle method call in middle of statement)
1 parent 31a1ceb commit 526d8b7

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

lib/checkclass.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,6 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
573573
assignVar(ftok->next()->varId(), scope, usage);
574574
}
575575

576-
// Before a new statement there is "[{};()=[]" or ::
577-
// We can also have a new statement after any operators or comparisons
578-
if (! Token::Match(ftok, "%op%|%comp%|{|}|;|(|)|=|[|::"))
579-
continue;
580-
581576
// If assignment comes after an && or || this is really inconclusive because of short circuiting
582577
if (Token::Match(ftok, "%oror%|&&"))
583578
continue;

test/testconstructors.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class TestConstructors : public TestFixture {
143143
TEST_CASE(uninitVar28); // ticket #6258
144144
TEST_CASE(uninitVar29);
145145
TEST_CASE(uninitVar30); // ticket #6417
146+
TEST_CASE(uninitVar31); // ticket #8271
146147
TEST_CASE(uninitVarEnum);
147148
TEST_CASE(uninitVarStream);
148149
TEST_CASE(uninitVarTypedef);
@@ -2327,6 +2328,24 @@ class TestConstructors : public TestFixture {
23272328
ASSERT_EQUALS("", errout.str());
23282329
}
23292330

2331+
void uninitVar31() { // ticket #8271
2332+
check("void bar();\n"
2333+
"class MyClass {\n"
2334+
"public:\n"
2335+
" MyClass();\n"
2336+
" void Restart();\n"
2337+
"protected:\n"
2338+
" int m_retCode;\n"
2339+
"};\n"
2340+
"MyClass::MyClass() {\n"
2341+
" bar(),Restart();\n"
2342+
"}\n"
2343+
"void MyClass::Restart() {\n"
2344+
" m_retCode = 0;\n"
2345+
"}\n");
2346+
ASSERT_EQUALS("", errout.str());
2347+
}
2348+
23302349
void uninitVarArray1() {
23312350
check("class John\n"
23322351
"{\n"

0 commit comments

Comments
 (0)