fix wrong information about constness of function

This commit is contained in:
Robert Reif 2011-09-16 18:07:25 -04:00
parent cce4303f28
commit 1717bda382
2 changed files with 19 additions and 0 deletions

View File

@ -1606,6 +1606,13 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Token *tok)
break;
}
// streaming: >>
else if (tok1->str() == ">>" && isMemberVar(scope, tok1->next()))
{
isconst = false;
break;
}
// increment/decrement (member variable?)..
else if (Token::Match(tok1, "++|--"))
{

View File

@ -184,6 +184,7 @@ private:
TEST_CASE(const51); // ticket #3040
TEST_CASE(const52); // ticket #3049
TEST_CASE(const53); // ticket #3052
TEST_CASE(const54);
TEST_CASE(assigningPointerToPointerIsNotAConstOperation);
TEST_CASE(assigningArrayElementIsNotAConstOperation);
TEST_CASE(constoperator1); // operator< can often be const
@ -5742,6 +5743,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void const54()
{
checkConst("class MyObject {\n"
" int tmp;\n"
" MyObject() : tmp(0) {}\n"
"public:\n"
" void set(std::stringstream &in) { in >> tmp; }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void assigningPointerToPointerIsNotAConstOperation()
{
checkConst("struct s\n"