From 458f0da197b38b676c16a04050e768356b637ccd Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 24 Dec 2015 17:08:49 +0300 Subject: [PATCH] Reduce variable scope, better name --- lib/checkclass.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index e25d0c836..de95d1bf5 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1876,10 +1876,11 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool& if (lhs->astParent()->strAt(1) != "const") return false; } else { - const Variable* v2 = lhs->previous()->variable(); - if (lhs->tokType() == Token::eAssignmentOp && v2) - if (!v2->isConst() && v2->isReference() && lhs == v2->nameToken()->next()) + if (lhs->tokType() == Token::eAssignmentOp) { + const Variable* lhsVar = lhs->previous()->variable(); + if (lhsVar && !lhsVar->isConst() && lhsVar->isReference() && lhs == lhsVar->nameToken()->next()) return false; + } } const Token* jumpBackToken = nullptr;