another variation of false negative from #3149
This commit is contained in:
parent
2193572c9e
commit
272783347b
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue