Fixed #3159 (Uninitialized variable false positive)
This commit is contained in:
parent
480c403511
commit
417dc1ff2a
|
@ -498,7 +498,7 @@ private:
|
|||
bool assignment = false;
|
||||
for (const Token *tok2 = tok.next(); tok2 && tok2->str() != ";"; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->str() == "=" || tok2->str() == ">>" || tok2->str() == "?")
|
||||
if (tok2->str() == "=" || tok2->str() == ">>" || tok2->str() == "?" || Token::Match(tok2, "(|, &"))
|
||||
{
|
||||
assignment = true;
|
||||
break;
|
||||
|
|
|
@ -1568,6 +1568,19 @@ private:
|
|||
" buf[1] = buf[0];\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #3159 - initialization by function
|
||||
checkUninitVar("static int isnumber(const char *arg) {\n"
|
||||
" char *p;\n"
|
||||
" return strtod(arg, &p) != 0 || p != arg;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("static int isnumber(const char *arg) {\n"
|
||||
" char *p;\n"
|
||||
" return strtod(&arg) != 0 || p != arg;\n"
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("error", "", errout.str());
|
||||
}
|
||||
|
||||
// valid and invalid use of 'int a(int x) { return x + x; }'
|
||||
|
|
Loading…
Reference in New Issue