Uninitialized variables: Fixed false negative. Ticket: #2207
This commit is contained in:
parent
77a5d4e399
commit
cbdae275ed
|
@ -465,7 +465,7 @@ private:
|
|||
}
|
||||
|
||||
// Used..
|
||||
if (Token::Match(tok.previous(), "[[(,+-*/] %var% []),+-*/]"))
|
||||
if (Token::Match(tok.previous(), "[[(,+-*/] %var% []),;+-*/]"))
|
||||
{
|
||||
use(checks, &tok);
|
||||
return &tok;
|
||||
|
|
|
@ -66,6 +66,13 @@ private:
|
|||
|
||||
void uninitvar1()
|
||||
{
|
||||
// Ticket #2207 - False negative
|
||||
checkUninitVar("void foo() {\n"
|
||||
" int a;\n"
|
||||
" b = c - a;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
// dereferencing uninitialized pointer..
|
||||
checkUninitVar("static void foo()\n"
|
||||
"{\n"
|
||||
|
@ -546,16 +553,6 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #2207 - False negative
|
||||
checkUninitVar("void foo(int x) {\n"
|
||||
" int a;\n"
|
||||
" if (x)\n"
|
||||
" a = 1;\n"
|
||||
" b = c - a;\n"
|
||||
"}\n");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:5] (error) uninitialized variable a", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #2207 - False positive
|
||||
checkUninitVar("void foo(int x) {\n"
|
||||
" int a;\n"
|
||||
|
|
Loading…
Reference in New Issue