@@ -1692,11 +1692,7 @@ void CheckClass::checkConst()
16921692
16931693 for (func = scope->functionList .begin (); func != scope->functionList .end (); ++func) {
16941694 // does the function have a body?
1695- if (func->type != Function::eFunction || !func->hasBody ())
1696- continue ;
1697-
1698- // don't warn for friend/static/virtual methods
1699- if (func->isFriend () || func->isStatic () || func->isVirtual ())
1695+ if (func->type != Function::eFunction || !func->hasBody () || func->isFriend () || func->isStatic () || func->isVirtual ())
17001696 continue ;
17011697
17021698 // get last token of return type
@@ -1732,36 +1728,36 @@ void CheckClass::checkConst()
17321728 }
17331729
17341730 // check if base class function is virtual
1735- if (!scope->definedType ->derivedFrom .empty () && !func->isImplicitlyVirtual (true ))
1736- continue ;
1731+ if (!scope->definedType ->derivedFrom .empty ()) {
1732+ if (func->isImplicitlyVirtual (true ))
1733+ continue ;
1734+ }
17371735
17381736 bool memberAccessed = false ;
17391737 // if nothing non-const was found. write error..
1740- if (!checkConstFunc (scope, &*func, memberAccessed))
1741- continue ;
1742-
1743- if (func->isConst () && (memberAccessed || func->isOperator ()))
1744- continue ;
1745-
1746- std::string classname = scope->className ;
1747- const Scope *nest = scope->nestedIn ;
1748- while (nest && nest->type != Scope::eGlobal) {
1749- classname = std::string (nest->className + " ::" + classname);
1750- nest = nest->nestedIn ;
1751- }
1738+ if (checkConstFunc (scope, &*func, memberAccessed)) {
1739+ std::string classname = scope->className ;
1740+ const Scope *nest = scope->nestedIn ;
1741+ while (nest && nest->type != Scope::eGlobal) {
1742+ classname = std::string (nest->className + " ::" + classname);
1743+ nest = nest->nestedIn ;
1744+ }
17521745
1753- // get function name
1754- std::string functionName = (func->tokenDef ->isName () ? " " : " operator" ) + func->tokenDef ->str ();
1746+ // get function name
1747+ std::string functionName = (func->tokenDef ->isName () ? " " : " operator" ) + func->tokenDef ->str ();
17551748
1756- if (func->tokenDef ->str () == " (" )
1757- functionName += " )" ;
1758- else if (func->tokenDef ->str () == " [" )
1759- functionName += " ]" ;
1749+ if (func->tokenDef ->str () == " (" )
1750+ functionName += " )" ;
1751+ else if (func->tokenDef ->str () == " [" )
1752+ functionName += " ]" ;
17601753
1761- if (func->isInline ())
1762- checkConstError (func->token , classname, functionName, !memberAccessed && !func->isOperator ());
1763- else // not inline
1764- checkConstError2 (func->token , func->tokenDef , classname, functionName, !memberAccessed && !func->isOperator ());
1754+ if (!func->isConst () || (!memberAccessed && !func->isOperator ())) {
1755+ if (func->isInline ())
1756+ checkConstError (func->token , classname, functionName, !memberAccessed && !func->isOperator ());
1757+ else // not inline
1758+ checkConstError2 (func->token , func->tokenDef , classname, functionName, !memberAccessed && !func->isOperator ());
1759+ }
1760+ }
17651761 }
17661762 }
17671763}
0 commit comments