From db123c2c9bf1130b1076d08ca1dc2d677d031923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 25 Dec 2012 12:50:38 +0100 Subject: [PATCH] Fixed #4431 (FP: Erroneous 'Ineffective call of function empty()' in ?: test) --- lib/checkstl.cpp | 2 +- test/teststl.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 7abf505f9..b556bdab5 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1408,7 +1408,7 @@ void CheckStl::uselessCalls() uselessCallsSubstrError(tok, false); } else if (Token::simpleMatch(tok->linkAt(2)->tokAt(-2), ", 0 )")) uselessCallsSubstrError(tok, true); - } else if (Token::Match(tok, "[{}:;] %var% . empty ( ) ;") && style) + } else if (Token::Match(tok, "[{};] %var% . empty ( ) ;") && style) uselessCallsEmptyError(tok->next()); else if (Token::Match(tok, "[{};] std :: remove|remove_if|unique (") && tok->tokAt(5)->nextArgument()) uselessCallsRemoveError(tok->next(), tok->strAt(3)); diff --git a/test/teststl.cpp b/test/teststl.cpp index ea6922f4d..59cf9b639 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -2124,6 +2124,12 @@ private: ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of std::remove() ignored. Elements remain in container.\n" "[test.cpp:3]: (warning) Return value of std::remove_if() ignored. Elements remain in container.\n" "[test.cpp:4]: (warning) Return value of std::unique() ignored. Elements remain in container.\n", errout.str()); + + // #4431 - fp + check("bool f() {\n" + " return x ? true : (y.empty());\n" + "}"); + ASSERT_EQUALS("", errout.str()); } };