Fixed #3058 (False positive: Uninitialized variable: data)

This commit is contained in:
Daniel Marjamäki 2011-09-03 18:53:14 +02:00
parent 7cb5c97e7d
commit c7886ca1c4
2 changed files with 12 additions and 1 deletions

View File

@ -510,6 +510,10 @@ private:
// Used..
if (Token::Match(tok.previous(), "[[(,+-*/|=] %var% ]|)|,|;|%op%"))
{
// initialize reference variable
if (Token::Match(tok.tokAt(-3), "& %var% ="))
bailOutVar(checks, tok.varId());
else
use(checks, &tok);
return &tok;
}

View File

@ -155,6 +155,13 @@ private:
"}\n");
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"
"{\n"
" int x = xyz::x;\n"