Fixed false positive #6717
This commit is contained in:
parent
dd9cb929bf
commit
bdd53b4142
|
@ -1965,7 +1965,7 @@ bool CheckUninitVar::isMemberVariableUsage(const Token *tok, bool isPointer, All
|
|||
if (isMemberVariableAssignment(tok, membervar))
|
||||
return false;
|
||||
|
||||
if (Token::Match(tok, "%name% . %name%") && tok->strAt(2) == membervar)
|
||||
if (Token::Match(tok, "%name% . %name%") && tok->strAt(2) == membervar && !(tok->tokAt(-2)->variable() && tok->tokAt(-2)->variable()->isReference()))
|
||||
return true;
|
||||
else if (!isPointer && Token::Match(tok->previous(), "[(,] %name% [,)]") && isVariableUsage(tok, isPointer, alloc))
|
||||
return true;
|
||||
|
|
|
@ -1705,6 +1705,15 @@ private:
|
|||
" strchr(s.c_str(), ',');\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #6717
|
||||
checkUninitVarB("void f() {\n"
|
||||
" struct thing { int value; };\n"
|
||||
" thing it;\n"
|
||||
" int& referenced_int = it.value;\n"
|
||||
" referenced_int = 123;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar_return() {
|
||||
|
|
Loading…
Reference in New Issue