Fixed #1259 (false postive: Member variable 'A::b' is not assigned a value in 'A::operator=')
This commit is contained in:
parent
2358c51694
commit
2de49129dc
|
@ -315,6 +315,12 @@ void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *va
|
||||||
initVar(varlist, ftok->strAt(0));
|
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?
|
// Assignment of array item of member variable?
|
||||||
else if (Token::Match(ftok, "* %var% ="))
|
else if (Token::Match(ftok, "* %var% ="))
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ private:
|
||||||
TEST_CASE(uninitVarTypedef);
|
TEST_CASE(uninitVarTypedef);
|
||||||
TEST_CASE(uninitVarArray1);
|
TEST_CASE(uninitVarArray1);
|
||||||
TEST_CASE(uninitVarArray2);
|
TEST_CASE(uninitVarArray2);
|
||||||
|
TEST_CASE(uninitVarArray2D);
|
||||||
TEST_CASE(uninitMissingFuncDef);// can't expand function in constructor
|
TEST_CASE(uninitMissingFuncDef);// can't expand function in constructor
|
||||||
TEST_CASE(privateCtor1); // If constructor is private..
|
TEST_CASE(privateCtor1); // If constructor is private..
|
||||||
TEST_CASE(privateCtor2); // If constructor is private..
|
TEST_CASE(privateCtor2); // If constructor is private..
|
||||||
|
@ -1115,6 +1116,19 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
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()
|
void uninitMissingFuncDef()
|
||||||
{
|
{
|
||||||
// Unknown member function
|
// Unknown member function
|
||||||
|
|
Loading…
Reference in New Issue