Uninitialized variables: Fixed false negative when ? operator is used in rhs
This commit is contained in:
parent
a15dac9285
commit
e2964c0c9e
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue