Uninitialized variables: Fixed false positive in for condition. Ticket: #3369
This commit is contained in:
parent
40f2f4f7f6
commit
d2d7e25f3f
|
@ -1124,7 +1124,7 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const unsigned int
|
|||
}
|
||||
|
||||
// TODO: handle loops, try, etc
|
||||
if (Token::simpleMatch(tok, ") {") || Token::Match(tok, "%var% {")) {
|
||||
if (tok->str() == "for" || Token::simpleMatch(tok, ") {") || Token::Match(tok, "%var% {")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1792,6 +1792,14 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("void f() {\n"
|
||||
" int x;\n"
|
||||
" for (int i = 0; i < 10; i += x) {\n"
|
||||
" x = y;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// try
|
||||
checkUninitVar2("void f() {\n"
|
||||
" int i, *p = &i;\n"
|
||||
|
|
Loading…
Reference in New Issue