Fixed false positive: checkMisusedScopedObject no longer errors on calls to function objects.

This commit is contained in:
Pete Johns 2010-10-02 21:16:50 +10:00
parent 9a9302cba1
commit 365b1bed1a
2 changed files with 7 additions and 7 deletions

View File

@ -3883,10 +3883,11 @@ void CheckOther::checkMisusedScopedObject()
withinFunction = false;
}
if (withinFunction
&& Token::Match(tok, "[;{}] %var% (")
if (withinFunction
&& Token::Match(tok, "[;{}] %var% (")
&& isIdentifierObjectType(tok)
&& !Token::Match(tok->tokAt(2)->link(), ") .")
&& !Token::Match(tok->tokAt(2)->link(), ") ( %var%")
&& !Token::simpleMatch(tok->tokAt(2)->link(), ") .")
)
{
tok = tok->next();

View File

@ -3120,10 +3120,9 @@ private:
"\n"
"int main()\n"
"{\n"
" int a[] = {1, 2, 3, 4, 5};\n"
" const size_t n = sizeof a / sizeof a[0];\n"
" std::for_each(a, a + n, IncrementFunctor());\n"
" return a[0];\n"
" int a = 1;\n"
" IncrementFunctor()(a);\n"
" return a;\n"
"}\n"
);
ASSERT_EQUALS("", errout.str());