Fixed #2226 (segmentation fault of cppcheck)
This commit is contained in:
parent
c685035ca4
commit
fc57e06cdd
|
@ -790,13 +790,15 @@ private:
|
|||
const Token *tok2;
|
||||
|
||||
// parse setup
|
||||
for (tok2 = tok.tokAt(3); tok2; tok2 = tok2->next())
|
||||
for (tok2 = tok.tokAt(3); tok2 != tok.link(); tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->str() == ";")
|
||||
break;
|
||||
if (tok2->varId())
|
||||
varid1.insert(tok2->varId());
|
||||
}
|
||||
if (tok2 == tok.link())
|
||||
return &tok;
|
||||
|
||||
// parse condition
|
||||
if (Token::Match(tok2, "; %var% <|<=|>=|> %num% ;"))
|
||||
|
|
|
@ -757,6 +757,15 @@ private:
|
|||
" a++;"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
// Ticket #2226: C++0x loop
|
||||
checkUninitVar("void f() {\n"
|
||||
" container c;\n"
|
||||
" for (iterator it : c) {\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
|
||||
// switch..
|
||||
|
|
Loading…
Reference in New Issue