Uninitialized variable: Fixed test failure. Ticket: #3369
This commit is contained in:
parent
f797307edc
commit
167530bf60
|
@ -1132,7 +1132,7 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const unsigned int
|
||||||
if (Token::Match(tok, "return|break|continue|throw"))
|
if (Token::Match(tok, "return|break|continue|throw"))
|
||||||
ret = true;
|
ret = true;
|
||||||
else if (ret && tok->str() == ";")
|
else if (ret && tok->str() == ";")
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
// variable is seen..
|
// variable is seen..
|
||||||
if (tok->varId() == varid) {
|
if (tok->varId() == varid) {
|
||||||
|
|
|
@ -1774,6 +1774,14 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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
|
// for, while
|
||||||
checkUninitVar2("void f() {\n"
|
checkUninitVar2("void f() {\n"
|
||||||
" int x;\n"
|
" int x;\n"
|
||||||
|
|
Loading…
Reference in New Issue