Fixed #1200 (false positive 'uninitialized variable' when using throw)
This commit is contained in:
parent
b0d7623dcf
commit
071b7b463d
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue