Uninitialized variables: Fixed false negatives when calling unknown function with uninitialized variable by value: 'f(a+1)'
This commit is contained in:
parent
6836198a5c
commit
47d37e7a05
|
@ -677,7 +677,7 @@ private:
|
|||
}
|
||||
|
||||
// it is possible that the variable is initialized here
|
||||
if (Token::Match(tok2->previous(), "[(,] %var% [+-,)]"))
|
||||
if (Token::Match(tok2->previous(), "[(,] %var% [,)]"))
|
||||
bailouts.insert(tok2->varId());
|
||||
|
||||
// array initialization..
|
||||
|
@ -689,7 +689,7 @@ private:
|
|||
if ((*it)->varId == tok2->varId())
|
||||
{
|
||||
const UninitVar *c = dynamic_cast<const UninitVar *>(*it);
|
||||
if (c && c->array)
|
||||
if (c && (c->array || (c->pointer && c->alloc)))
|
||||
bailouts.insert(tok2->varId());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1178,6 +1178,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: f\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" int i;\n"
|
||||
" x(i+2);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: i\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" char *p = malloc(10);\n"
|
||||
|
|
Loading…
Reference in New Issue