Fixed #2265 (False positive: Uninitialized variable: path)

This commit is contained in:
Daniel Marjamäki 2010-11-30 18:40:36 +01:00
parent 065af5c444
commit 234b1e0098
2 changed files with 17 additions and 4 deletions

View File

@ -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)
tok3 = tok3->next()->link(); {
if (Token::simpleMatch(tok3, "] =")) if (Token::Match(tok3->next(), ". %var%"))
tok3 = tok3->tokAt(2);
else if (tok3->strAt(1) == "[")
tok3 = tok3->next()->link();
else
break;
}
if (tok3->strAt(1) == "=")
continue; continue;
} }
bool foundError; bool foundError;

View File

@ -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..