Fixed #1815 (False positive: uninitialized variable when using ? operator)
This commit is contained in:
parent
b33fb48618
commit
c6888845a0
|
@ -2945,7 +2945,7 @@ private:
|
|||
// check variable usages in rhs/index
|
||||
for (const Token *tok2 = tok.tokAt(2); tok2; tok2 = tok2->next())
|
||||
{
|
||||
if (Token::Match(tok2, ";|)|="))
|
||||
if (Token::Match(tok2, ";|)|=|?"))
|
||||
break;
|
||||
if (Token::Match(tok2, "%var% ("))
|
||||
break;
|
||||
|
|
|
@ -1681,6 +1681,16 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ? :
|
||||
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());
|
||||
|
||||
// while..
|
||||
checkUninitVar("int f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue