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