Fixed #1722 (Member variable initialized in call to base class constructor)
This commit is contained in:
parent
f75ca79849
commit
68ad8219ed
|
@ -238,6 +238,11 @@ void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *va
|
|||
if (Assign && Token::Match(ftok, "%var% ("))
|
||||
{
|
||||
initVar(varlist, ftok->strAt(0));
|
||||
|
||||
// assignment in the initializer..
|
||||
// : var(value = x)
|
||||
if (Token::Match(ftok->tokAt(2), "%var% ="))
|
||||
initVar(varlist, ftok->strAt(2));
|
||||
}
|
||||
|
||||
Assign |= (ftok->str() == ":");
|
||||
|
|
|
@ -49,6 +49,7 @@ private:
|
|||
TEST_CASE(uninitVar3);
|
||||
TEST_CASE(uninitVar4);
|
||||
TEST_CASE(uninitVar5);
|
||||
TEST_CASE(uninitVar6);
|
||||
TEST_CASE(uninitVarEnum);
|
||||
TEST_CASE(uninitVarStream);
|
||||
TEST_CASE(uninitVarTypedef);
|
||||
|
@ -1524,6 +1525,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVar6()
|
||||
{
|
||||
checkUninitVar("class Foo : public Bar\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" Foo(int i) : Bar(mi=i) { }\n"
|
||||
"private:\n"
|
||||
" int mi;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarArray1()
|
||||
{
|
||||
checkUninitVar("class John\n"
|
||||
|
|
Loading…
Reference in New Issue