Fixed #2265 (False positive: Uninitialized variable: path)
This commit is contained in:
parent
065af5c444
commit
234b1e0098
|
@ -379,12 +379,19 @@ private:
|
||||||
!Token::simpleMatch(tok2->next(), "="))
|
!Token::simpleMatch(tok2->next(), "="))
|
||||||
{
|
{
|
||||||
// Multiple assignments..
|
// Multiple assignments..
|
||||||
if (Token::simpleMatch(tok2->next(), "["))
|
if (Token::Match(tok2->next(), ".|["))
|
||||||
{
|
{
|
||||||
const Token * tok3 = tok2;
|
const Token * tok3 = tok2;
|
||||||
while (Token::simpleMatch(tok3->next(), "["))
|
while (tok3)
|
||||||
|
{
|
||||||
|
if (Token::Match(tok3->next(), ". %var%"))
|
||||||
|
tok3 = tok3->tokAt(2);
|
||||||
|
else if (tok3->strAt(1) == "[")
|
||||||
tok3 = tok3->next()->link();
|
tok3 = tok3->next()->link();
|
||||||
if (Token::simpleMatch(tok3, "] ="))
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (tok3->strAt(1) == "=")
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool foundError;
|
bool foundError;
|
||||||
|
|
|
@ -1108,6 +1108,12 @@ private:
|
||||||
" return i;\n"
|
" return i;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void f(int x) {\n"
|
||||||
|
" struct AB ab;\n"
|
||||||
|
" x = ab.x = 12;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// enum..
|
// enum..
|
||||||
|
|
Loading…
Reference in New Issue