Fixed #1200 (false positive 'uninitialized variable' when using throw)

This commit is contained in:
Daniel Marjamäki 2010-01-01 20:12:39 +01:00
parent b0d7623dcf
commit 071b7b463d
2 changed files with 13 additions and 2 deletions

View File

@ -181,8 +181,8 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
return tok;
}
// return ends all execution paths
if (tok->str() == "return")
// return/throw ends all execution paths
if (tok->str() == "return" || tok->str() == "throw")
{
ExecutionPath::bailOut(checks);
}

View File

@ -1245,6 +1245,17 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("int foo()\n"
"{\n"
" int ret;\n"
" if (one())\n"
" ret = 1;\n"
" else\n"
" throw 3;\n"
" return ret;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("int f(int a)\n"
"{\n"
" int ret;\n"