Fixed #1855 (false positive: uninitialized variable (function call in switch condition))
This commit is contained in:
parent
020a8a965c
commit
1fb4758583
|
@ -192,6 +192,13 @@ static void checkExecutionPaths_(const Token *tok, std::list<ExecutionPath *> &c
|
|||
|
||||
if (tok->str() == "switch")
|
||||
{
|
||||
// parse condition
|
||||
if (checks.size() > 10 || check->parseCondition(*tok->next(), checks))
|
||||
{
|
||||
ExecutionPath::bailOut(checks);
|
||||
return;
|
||||
}
|
||||
|
||||
const Token *tok2 = tok->next()->link();
|
||||
if (Token::simpleMatch(tok2, ") { case"))
|
||||
{
|
||||
|
|
|
@ -1834,6 +1834,18 @@ private:
|
|||
" } catch (...) {\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
|
||||
// #1855 - switch(foo(&x))
|
||||
checkUninitVar("int a()\n"
|
||||
"{\n"
|
||||
" int x;\n"
|
||||
" switch (foo(&x))\n"
|
||||
" {\n"
|
||||
" case 1:\n"
|
||||
" return x;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// arrays..
|
||||
|
|
Loading…
Reference in New Issue