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")
|
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();
|
const Token *tok2 = tok->next()->link();
|
||||||
if (Token::simpleMatch(tok2, ") { case"))
|
if (Token::simpleMatch(tok2, ") { case"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1834,6 +1834,18 @@ private:
|
||||||
" } catch (...) {\n"
|
" } catch (...) {\n"
|
||||||
" }\n"
|
" }\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..
|
// arrays..
|
||||||
|
|
Loading…
Reference in New Issue