Fixed false positive: checkMisusedScopedObject no longer errors on calls to function objects.
This commit is contained in:
parent
9a9302cba1
commit
365b1bed1a
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue