parent
3109d16b42
commit
eeda0442fa
|
@ -1367,16 +1367,16 @@ void CheckOther::checkConstVariable()
|
|||
if (Function::returnsReference(function)) {
|
||||
std::vector<const Token*> returns = Function::findReturns(function);
|
||||
if (std::any_of(returns.begin(), returns.end(), [&](const Token* retTok) {
|
||||
if (retTok->varId() == var->declarationId())
|
||||
return true;
|
||||
while (Token::simpleMatch(retTok, "."))
|
||||
retTok = retTok->astOperand2();
|
||||
const Variable* retVar = getLifetimeVariable(getParentLifetime(retTok));
|
||||
if (!retVar)
|
||||
return false;
|
||||
return retVar->declarationId() == var->declarationId();
|
||||
}))
|
||||
continue;
|
||||
if (retTok->varId() == var->declarationId())
|
||||
return true;
|
||||
while (Token::simpleMatch(retTok, "."))
|
||||
retTok = retTok->astOperand2();
|
||||
const Variable* retVar = getLifetimeVariable(getParentLifetime(retTok));
|
||||
if (!retVar)
|
||||
return false;
|
||||
return retVar->declarationId() == var->declarationId();
|
||||
}))
|
||||
continue;
|
||||
}
|
||||
// Skip if address is taken
|
||||
if (Token::findmatch(var->nameToken(), "& %varid%", scope->bodyEnd, var->declarationId()))
|
||||
|
|
Loading…
Reference in New Issue