Fixed #4852 (false positive: Member variable 'A::sz' is not initialized in the constructor)

This commit is contained in:
Robert Reif 2013-06-14 06:32:26 +02:00 committed by Daniel Marjamäki
parent ae65a47f5f
commit 870d29944b
2 changed files with 16 additions and 2 deletions

View File

@ -494,8 +494,8 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
assignVar(ftok->strAt(1), scope, usage);
}
// Before a new statement there is "[{};)=]"
if (! Token::Match(ftok, "[{};()=]"))
// Before a new statement there is "[{};()=[]"
if (! Token::Match(ftok, "[{};()=[]"))
continue;
if (Token::simpleMatch(ftok, "( !"))

View File

@ -119,6 +119,7 @@ private:
TEST_CASE(uninitVar23); // ticket #3702
TEST_CASE(uninitVar24); // ticket #3190
TEST_CASE(uninitVar25); // ticket #4789
TEST_CASE(uninitVar26);
TEST_CASE(uninitVarEnum);
TEST_CASE(uninitVarStream);
TEST_CASE(uninitVarTypedef);
@ -1890,6 +1891,19 @@ private:
"[test.cpp:42]: (warning) Member variable 'F::c' is not initialized in the constructor.\n", errout.str());
}
void uninitVar26()
{
check("class A {\n"
" int * v;\n"
" int sz;\n"
"public:\n"
" A(int s) {\n"
" v = new int [sz = s];\n"
" }\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void uninitVarArray1() {
check("class John\n"
"{\n"