another variation of false negative from #3149

This commit is contained in:
Robert Reif 2011-09-30 16:26:08 -04:00
parent 2193572c9e
commit 272783347b
2 changed files with 9 additions and 1 deletions

View File

@ -1663,7 +1663,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Token *tok)
// function call..
else if (Token::Match(tok1, "%var% (") &&
!(Token::Match(tok1, "return|c_str|if|string|switch|while|catch") || tok1->isStandardType()))
!(Token::Match(tok1, "return|c_str|if|string|switch|while|catch|for") || tok1->isStandardType()))
{
if (!isConstMemberFunc(scope, tok1))
{

View File

@ -5809,6 +5809,14 @@ private:
" return RET_NOK;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:4]: (information) Technically the member function 'A::f' can be const.\n", errout.str());
checkConst("class MyObject {\n"
"public:\n"
" void foo(int x) {\n"
" for (int i = 0; i < 5; i++) { }\n"
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:3]: (information) Technically the member function 'MyObject::foo' can be const.\n", errout.str());
}
void assigningPointerToPointerIsNotAConstOperation()