Fixed #1304 (False positive: The function 'x' can be const when modifing a member)

This commit is contained in:
Daniel Marjamäki 2010-01-23 20:59:20 +01:00
parent 5b76be4935
commit 9a6b450501
2 changed files with 18 additions and 1 deletions

View File

@ -1455,8 +1455,18 @@ void CheckClass::checkConst()
break;
--indentlevel;
}
// assignment.. = += |= ..
else if (tok3->str() == "=" ||
Token::Match(tok, "%var% ("))
(tok3->str().find("=") == 1 &&
tok3->str().find_first_of("<>") == std::string::npos))
{
isconst = false;
break;
}
// function call..
else if (Token::Match(tok, "%var% ("))
{
isconst = false;
break;

View File

@ -1539,6 +1539,13 @@ private:
"};\n");
ASSERT_EQUALS("", errout.str());
// assignment through |=..
checkConst("class Fred {\n"
" int a;\n"
" int setA() { a |= true; }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};