Fixed #1182 (False positive: uninitialized variable 'int *pa = &a;')
This commit is contained in:
parent
6c0919d9bd
commit
0ee3d7e46a
|
@ -1537,7 +1537,9 @@ private:
|
|||
break;
|
||||
if (Token::Match(tok2, "%var% ("))
|
||||
break;
|
||||
if (tok2->varId() && !Token::simpleMatch(tok2->next(), "="))
|
||||
if (tok2->varId() &&
|
||||
!Token::simpleMatch(tok2->previous(), "&") &&
|
||||
!Token::simpleMatch(tok2->next(), "="))
|
||||
use(foundError, checks, tok2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1020,6 +1020,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: x\n", errout.str());
|
||||
|
||||
checkUninitVar("void foo()\n"
|
||||
"{\n"
|
||||
" int x;\n"
|
||||
" int *y = &x;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("static int foo()\n"
|
||||
"{\n"
|
||||
" int ret;\n"
|
||||
|
|
Loading…
Reference in New Issue