Uninitialized variables: Fixed false negative when ? operator is used in rhs

This commit is contained in:
Daniel Marjamäki 2012-06-23 12:19:03 +02:00
parent a15dac9285
commit e2964c0c9e
2 changed files with 2 additions and 4 deletions

View File

@ -348,7 +348,7 @@ private:
void parserhs(const Token *tok2, std::list<ExecutionPath *> &checks) const {
// check variable usages in rhs/index
while (NULL != (tok2 = tok2->next())) {
if (Token::Match(tok2, "[;)=?]"))
if (Token::Match(tok2, "[;)=]"))
break;
if (Token::Match(tok2, "%var% ("))
break;

View File

@ -778,11 +778,9 @@ private:
checkUninitVar("static void foo(int v)\n"
"{\n"
" int x;\n"
" if (v > 0)\n"
" v = func(&x);\n"
" x = v <= 0 ? -1 : x;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: x\n", errout.str());
checkUninitVar("void foo()\n"
"{\n"