From 365b1bed1a51edf6262375f511a0a47d37ff1191 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Sat, 2 Oct 2010 21:16:50 +1000 Subject: [PATCH] Fixed false positive: checkMisusedScopedObject no longer errors on calls to function objects. --- lib/checkother.cpp | 7 ++++--- test/testother.cpp | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 5636f55a4..17ce079d6 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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(); diff --git a/test/testother.cpp b/test/testother.cpp index 3b5ff0f3d..4e52b0487 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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());