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()) if (func.isFriend() || func.isStatic() || func.hasVirtualSpecifier())
continue; continue;
// is non-const pointer/reference returned? // don't warn when returning non-const pointer/reference
{ {
bool isConst = false;
bool isPointerOrReference = false; bool isPointerOrReference = false;
for (const Token *typeToken = func.retDef; typeToken; typeToken = typeToken->next()) { for (const Token *typeToken = func.retDef; typeToken; typeToken = typeToken->next()) {
if (Token::Match(typeToken, "(|{|;")) if (Token::Match(typeToken, "(|{|;"))
break; break;
if (!isPointerOrReference && typeToken->str() == "const") { if (!isPointerOrReference && typeToken->str() == "const")
isConst = true;
break; break;
}
if (Token::Match(typeToken, "*|&")) { if (Token::Match(typeToken, "*|&")) {
isPointerOrReference = true; isPointerOrReference = true;
break; break;