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,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;
} }

View File

@ -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"