Fixed #1376 (Member variable not initialized in the constructor false positive)
This commit is contained in:
parent
faced1b483
commit
0a6aa0f094
|
@ -277,6 +277,14 @@ void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *va
|
|||
break;
|
||||
}
|
||||
|
||||
// Clearing array..
|
||||
else if (Token::Match(ftok, "memset ( %var% ,"))
|
||||
{
|
||||
initVar(varlist, ftok->strAt(2));
|
||||
ftok = ftok->next()->link();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calling member function?
|
||||
else if (Token::Match(ftok, "%var% ("))
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
TEST_CASE(uninitVarTypedef);
|
||||
TEST_CASE(uninitVarArray1);
|
||||
TEST_CASE(uninitVarArray2);
|
||||
TEST_CASE(uninitVarArray3);
|
||||
TEST_CASE(uninitVarArray2D);
|
||||
TEST_CASE(uninitMissingFuncDef);// can't expand function in constructor
|
||||
TEST_CASE(privateCtor1); // If constructor is private..
|
||||
|
@ -1136,6 +1137,24 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarArray3()
|
||||
{
|
||||
checkUninitVar("class John\n"
|
||||
"{\n"
|
||||
"private:\n"
|
||||
" int a[100];\n"
|
||||
" int b[100];\n"
|
||||
"\n"
|
||||
"public:\n"
|
||||
" John()\n"
|
||||
" {\n"
|
||||
" memset(a,0,sizeof(a));\n"
|
||||
" memset(b,0,sizeof(b));\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarArray2D()
|
||||
{
|
||||
checkUninitVar("class John\n"
|
||||
|
|
Loading…
Reference in New Issue