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

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

View File

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