Fixed #4426 (False positive: Unitialized variable warning when comparing addresses)
This commit is contained in:
parent
6770cc80be
commit
de2c133f6a
|
@ -1417,6 +1417,8 @@ bool CheckUninitVar::isVariableUsage(const Scope* scope, const Token *vartok, bo
|
|||
// is there something like: ; "*((&var ..expr.. =" => the variable is assigned
|
||||
if (vartok->previous()->str() == "&") {
|
||||
const Token *tok2 = vartok->tokAt(-2);
|
||||
if (tok2 && (tok2->isOp() || tok2->str() == "("))
|
||||
return false; // address of
|
||||
if (Token::simpleMatch(tok2,")"))
|
||||
tok2 = tok2->link()->previous();
|
||||
while (tok2 && tok2->str() == "(")
|
||||
|
|
|
@ -2321,6 +2321,13 @@ private:
|
|||
" return x;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// &
|
||||
checkUninitVar2("void f() {\n" // #4426 - address of uninitialized variable
|
||||
" int a,b;\n"
|
||||
" if (&a == &b);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// #3869 - reference variable
|
||||
|
|
Loading…
Reference in New Issue