Fixed #1259 (false postive: Member variable 'A::b' is not assigned a value in 'A::operator=')

This commit is contained in:
Daniel Marjamäki 2010-01-12 21:36:40 +01:00
parent 2358c51694
commit 2de49129dc
2 changed files with 21 additions and 1 deletions

View File

@ -315,6 +315,12 @@ void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *va
initVar(varlist, ftok->strAt(0));
}
// Assignment of array item of member variable?
else if (Token::Match(ftok, "%var% [ %any% ] [ %any% ] ="))
{
initVar(varlist, ftok->strAt(0));
}
// Assignment of array item of member variable?
else if (Token::Match(ftok, "* %var% ="))
{

View File

@ -51,6 +51,7 @@ private:
TEST_CASE(uninitVarTypedef);
TEST_CASE(uninitVarArray1);
TEST_CASE(uninitVarArray2);
TEST_CASE(uninitVarArray2D);
TEST_CASE(uninitMissingFuncDef);// can't expand function in constructor
TEST_CASE(privateCtor1); // If constructor is private..
TEST_CASE(privateCtor2); // If constructor is private..
@ -72,7 +73,7 @@ private:
TEST_CASE(operatorEqToSelf2); // nested class
TEST_CASE(operatorEqToSelf3); // multiple inheritance
TEST_CASE(operatorEqToSelf4); // nested class with multiple inheritance
TEST_CASE(operatorEqToSelf5); // ticket # 1233
TEST_CASE(operatorEqToSelf5); // ticket # 1233
TEST_CASE(memsetOnStruct);
TEST_CASE(memsetOnClass);
@ -1115,6 +1116,19 @@ private:
ASSERT_EQUALS("", errout.str());
}
void uninitVarArray2D()
{
checkUninitVar("class John\n"
"{\n"
"public:\n"
" John() { a[0][0] = 0; }\n"
"\n"
"private:\n"
" char a[2][2];\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void uninitMissingFuncDef()
{
// Unknown member function