only break when we know we are inc/dec a member variable in CheckClass::checkConstFunc

This commit is contained in:
Robert Reif 2011-03-25 23:22:28 -04:00
parent 168db82fd6
commit c27ecf5aeb
1 changed files with 9 additions and 1 deletions

View File

@ -1545,23 +1545,31 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Token *tok)
tok1->previous()->str() != "return") tok1->previous()->str() != "return")
{ {
if (isMemberVar(scope, tok1->previous())) if (isMemberVar(scope, tok1->previous()))
{
isconst = false; isconst = false;
break;
}
} }
// var[...]++ and var[...]-- // var[...]++ and var[...]--
else if (tok1->previous()->str() == "]") else if (tok1->previous()->str() == "]")
{ {
if (isMemberVar(scope, tok1->previous()->link()->previous())) if (isMemberVar(scope, tok1->previous()->link()->previous()))
{
isconst = false; isconst = false;
break;
}
} }
// ++var and --var // ++var and --var
else if (Token::Match(tok1->next(), "%var%")) else if (Token::Match(tok1->next(), "%var%"))
{ {
if (isMemberVar(scope, tok1->next())) if (isMemberVar(scope, tok1->next()))
{
isconst = false; isconst = false;
break;
}
} }
break;
} }
// function call.. // function call..