Fixed #4439 (False positive: Uninitialized variable (casting address))

This commit is contained in:
Daniel Marjamäki 2013-03-13 17:32:47 +01:00
parent 34b3fe6af0
commit 1f04e2c228
2 changed files with 8 additions and 0 deletions

View File

@ -1534,6 +1534,8 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool cpp
return false; // address of
if (tok2 && tok2->str() == ")")
tok2 = tok2->link()->previous();
if (Token::Match(tok2,") ( %type% *| ) &") && tok2->tokAt(2)->varId() == 0)
return false; // cast
while (tok2 && tok2->str() == "(")
tok2 = tok2->previous();
while (tok2 && tok2->str() == "*")

View File

@ -2344,6 +2344,12 @@ private:
" if (&a == &b);\n"
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar2("void f() {\n" // #4439 - cast address of uninitialized variable
" int a;\n"
" x((A)(B)&a);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
// #3869 - reference variable