Uninitialized variables. Fixed false positive when there are multiple related conditions. ticket: #2399
This commit is contained in:
parent
a0d62e041f
commit
68de938d23
|
@ -122,7 +122,7 @@ static void parseIfSwitchBody(const Token * const tok,
|
|||
std::list<ExecutionPath *>::const_iterator it;
|
||||
for (it = checks.begin(); it != checks.end(); ++it)
|
||||
{
|
||||
if (*(*it) == *c.back())
|
||||
if (*(*it) == *c.back() && (*it)->numberOfIf == c.back()->numberOfIf)
|
||||
{
|
||||
duplicate = true;
|
||||
countif2.erase((*it)->varId);
|
||||
|
|
|
@ -597,7 +597,8 @@ private:
|
|||
" }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (error) Dangerous iterator usage after erase()-method.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:9]: (error) Dangerous iterator usage after erase()-method.\n", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void eraseGoto()
|
||||
|
|
|
@ -637,6 +637,18 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int test(int cond1, int cond2) {\n"
|
||||
" int foo;\n"
|
||||
" if (cond1 || cond2) {\n"
|
||||
" if (cond2)\n"
|
||||
" foo = 0;\n"
|
||||
" }\n"
|
||||
" if (cond2) {\n"
|
||||
" int t = foo*foo;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ? :
|
||||
checkUninitVar("static void foo(int v)\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue