Fixed #1103 (false positive: uninitialized variable when using references)
This commit is contained in:
parent
368df4c083
commit
e03ff727d4
|
@ -1335,6 +1335,12 @@ private:
|
|||
|
||||
if (Token::simpleMatch(tok.previous(), "="))
|
||||
{
|
||||
if (Token::Match(tok.tokAt(-3), "& %var% ="))
|
||||
{
|
||||
bailOut(checks);
|
||||
return &tok;
|
||||
}
|
||||
|
||||
if (!Token::Match(tok.tokAt(-3), ". %var% ="))
|
||||
{
|
||||
if (!Token::Match(tok.tokAt(-3), "[;{}] %var% ="))
|
||||
|
|
|
@ -1258,6 +1258,16 @@ private:
|
|||
" } = { 0, 0 };\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// references..
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" int a;\n"
|
||||
" int &b = a;\n"
|
||||
" b = 0;\n"
|
||||
" int x = a;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue