From 671f1b83d9b407bd2fbe1ca10d12f53fa9141be1 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 27 Aug 2012 14:28:16 +0200 Subject: [PATCH] Fixed false positive: Return value of std::remove() ignored when std::remove(char*) is called (#4093) --- lib/checkstl.cpp | 2 +- test/teststl.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 74354bcc4..a0a4fb39b 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1340,7 +1340,7 @@ void CheckStl::uselessCalls() uselessCallsSubstrError(tok, true); } else if (Token::Match(tok, "[{}:;] %var% . empty ( ) ;") && style) uselessCallsEmptyError(tok->next()); - else if (Token::Match(tok, "[{};] std :: remove (")) + else if (Token::Match(tok, "[{};] std :: remove (") && tok->tokAt(5)->nextArgument()) uselessCallsRemoveError(tok->next()); } } diff --git a/test/teststl.cpp b/test/teststl.cpp index ca69de985..c1eaf328f 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1941,6 +1941,7 @@ private: " std::remove(a.begin(), a.end(), val);\n" " x = std::remove(a.begin(), a.end(), val);\n" " a.erase(std::remove(a.begin(), a.end(), val));\n" + " std::remove(\"foo.txt\");\n" "}\n"); ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of std::remove() ignored. Elements remain in container.\n", errout.str()); }