diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 82a078ce2..ef983bdfc 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1367,16 +1367,16 @@ void CheckOther::checkConstVariable() if (Function::returnsReference(function)) { std::vector 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()))