Fix Cppcheck warning

This commit is contained in:
Daniel Marjamäki 2020-07-24 19:58:36 +02:00
parent 6a839ad511
commit b4552dedb0
1 changed files with 2 additions and 5 deletions

View File

@ -1789,17 +1789,14 @@ void CheckClass::checkConst()
if (func.isFriend() || func.isStatic() || func.hasVirtualSpecifier())
continue;
// is non-const pointer/reference returned?
// don't warn when returning non-const pointer/reference
{
bool isConst = false;
bool isPointerOrReference = false;
for (const Token *typeToken = func.retDef; typeToken; typeToken = typeToken->next()) {
if (Token::Match(typeToken, "(|{|;"))
break;
if (!isPointerOrReference && typeToken->str() == "const") {
isConst = true;
if (!isPointerOrReference && typeToken->str() == "const")
break;
}
if (Token::Match(typeToken, "*|&")) {
isPointerOrReference = true;
break;