From b4552dedb05db4c9bb76cb46ef3e776be68d9ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 24 Jul 2020 19:58:36 +0200 Subject: [PATCH] Fix Cppcheck warning --- lib/checkclass.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 6f4b4ea43..45e733fa0 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -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;