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