Fixed #4778 (FP: Uninitialized variable: av)
This commit is contained in:
parent
870d29944b
commit
ae36472a1b
|
@ -1542,7 +1542,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool cpp
|
||||||
// is there something like: ; "*((&var ..expr.. =" => the variable is assigned
|
// is there something like: ; "*((&var ..expr.. =" => the variable is assigned
|
||||||
if (vartok->previous()->str() == "&") {
|
if (vartok->previous()->str() == "&") {
|
||||||
const Token *tok2 = vartok->tokAt(-2);
|
const Token *tok2 = vartok->tokAt(-2);
|
||||||
if (tok2 && (tok2->isConstOp() || tok2->str() == "("))
|
if (tok2 && (tok2->isConstOp() || Token::Match(tok2, "[;{}(]")))
|
||||||
return false; // address of
|
return false; // address of
|
||||||
if (tok2 && tok2->str() == ")")
|
if (tok2 && tok2->str() == ")")
|
||||||
tok2 = tok2->link()->previous();
|
tok2 = tok2->link()->previous();
|
||||||
|
|
|
@ -2376,6 +2376,12 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar2("void f() {\n" // #4778 - cast address of uninitialized variable
|
||||||
|
" long a;\n"
|
||||||
|
" &a;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkUninitVar2("void f() {\n" // #4717 - ({})
|
checkUninitVar2("void f() {\n" // #4717 - ({})
|
||||||
" int a = ({ long b = (long)(123); 2 + b; });\n"
|
" int a = ({ long b = (long)(123); 2 + b; });\n"
|
||||||
"}", "test.c", false);
|
"}", "test.c", false);
|
||||||
|
|
Loading…
Reference in New Issue