Uninitialized variable: Fixed test failure. Ticket: #3369

This commit is contained in:
Daniel Marjamäki 2011-12-15 20:15:37 +01:00
parent f797307edc
commit 167530bf60
2 changed files with 9 additions and 1 deletions

View File

@ -1132,7 +1132,7 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const unsigned int
if (Token::Match(tok, "return|break|continue|throw"))
ret = true;
else if (ret && tok->str() == ";")
return false;
return true;
// variable is seen..
if (tok->varId() == varid) {

View File

@ -1774,6 +1774,14 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar2("void f() {\n"
" int x;\n"
" return;\n"
"err:\n"
" return x;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// for, while
checkUninitVar2("void f() {\n"
" int x;\n"