Fix Cppcheck warning
This commit is contained in:
parent
6a839ad511
commit
b4552dedb0
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue