Execution Path: Fixed FP in improved handling of loop bodies

This commit is contained in:
Daniel Marjamäki 2010-10-24 19:14:40 +02:00
parent 8f707e5e46
commit 24a2def3ad
2 changed files with 15 additions and 0 deletions

View File

@ -260,6 +260,11 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
if (tok->str() != "switch")
{
for (const Token *tok3 = tok; tok3 && tok3 != tok2; tok3 = tok3->next())
{
if (tok3->varId())
ExecutionPath::bailOutVar(checks, tok3->varId());
}
check->parseLoopBody(tok2->next(), checks);
}

View File

@ -1769,6 +1769,16 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: k\n", errout.str());
checkUninitVar("enum ABCD { A, B, C, D };\n"
"\n"
"static void f(char *str ) {\n"
" enum ABCD i;\n"
" for (i = 0; i < D; i++) {\n"
" str[i] = 0;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// while..
checkUninitVar("int f()\n"
"{\n"