Fixed #3058 (False positive: Uninitialized variable: data)
This commit is contained in:
parent
7cb5c97e7d
commit
c7886ca1c4
|
@ -510,7 +510,11 @@ private:
|
||||||
// Used..
|
// Used..
|
||||||
if (Token::Match(tok.previous(), "[[(,+-*/|=] %var% ]|)|,|;|%op%"))
|
if (Token::Match(tok.previous(), "[[(,+-*/|=] %var% ]|)|,|;|%op%"))
|
||||||
{
|
{
|
||||||
use(checks, &tok);
|
// initialize reference variable
|
||||||
|
if (Token::Match(tok.tokAt(-3), "& %var% ="))
|
||||||
|
bailOutVar(checks, tok.varId());
|
||||||
|
else
|
||||||
|
use(checks, &tok);
|
||||||
return &tok;
|
return &tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,13 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" int *x;\n"
|
||||||
|
" int *&y = x;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkUninitVar("void foo()\n"
|
checkUninitVar("void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int x = xyz::x;\n"
|
" int x = xyz::x;\n"
|
||||||
|
|
Loading…
Reference in New Issue