Fixed #1553 (false positive : uninitialized variable for struct timeval from <sys/time>)
This commit is contained in:
parent
8b5aae9adb
commit
1dcbf02bd8
|
@ -409,6 +409,12 @@ void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *va
|
||||||
initVar(varlist, ftok->strAt(1));
|
initVar(varlist, ftok->strAt(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assignment of struct member of member variable?
|
||||||
|
else if (Token::Match(ftok, "%var% . %any% ="))
|
||||||
|
{
|
||||||
|
initVar(varlist, ftok->strAt(0));
|
||||||
|
}
|
||||||
|
|
||||||
// The functions 'clear' and 'Clear' are supposed to initialize variable.
|
// The functions 'clear' and 'Clear' are supposed to initialize variable.
|
||||||
if (Token::Match(ftok, "%var% . clear|Clear ("))
|
if (Token::Match(ftok, "%var% . clear|Clear ("))
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,7 @@ private:
|
||||||
TEST_CASE(uninitVar1);
|
TEST_CASE(uninitVar1);
|
||||||
TEST_CASE(uninitVar2);
|
TEST_CASE(uninitVar2);
|
||||||
TEST_CASE(uninitVar3);
|
TEST_CASE(uninitVar3);
|
||||||
|
TEST_CASE(uninitVar4);
|
||||||
TEST_CASE(uninitVarEnum);
|
TEST_CASE(uninitVarEnum);
|
||||||
TEST_CASE(uninitVarStream);
|
TEST_CASE(uninitVarStream);
|
||||||
TEST_CASE(uninitVarTypedef);
|
TEST_CASE(uninitVarTypedef);
|
||||||
|
@ -1160,6 +1161,21 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uninitVar4()
|
||||||
|
{
|
||||||
|
checkUninitVar("class Foo\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" Foo() { bar.x = 0; }\n"
|
||||||
|
"private:\n"
|
||||||
|
" struct Bar {\n"
|
||||||
|
" int x;\n"
|
||||||
|
" };\n"
|
||||||
|
" struct Bar bar;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void uninitVarArray1()
|
void uninitVarArray1()
|
||||||
{
|
{
|
||||||
checkUninitVar("class John\n"
|
checkUninitVar("class John\n"
|
||||||
|
|
Loading…
Reference in New Issue