Fixed #1305 (False positive: The function 'x' can be const when indirectly calling a non-const member)

This commit is contained in:
Daniel Marjamäki 2010-01-23 21:08:40 +01:00
parent 9a6b450501
commit aab05524e5
2 changed files with 9 additions and 1 deletions

View File

@ -1466,7 +1466,7 @@ void CheckClass::checkConst()
}
// function call..
else if (Token::Match(tok, "%var% ("))
else if (Token::Match(tok3, "%var% ("))
{
isconst = false;
break;

View File

@ -1546,6 +1546,14 @@ private:
"};\n");
ASSERT_EQUALS("", errout.str());
// functions with a function call can't be const..
checkConst("class foo\n"
"{\n"
"public:\n"
" int x;\n"
" void b() { a(); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};