Fixed #4431 (FP: Erroneous 'Ineffective call of function empty()' in ?: test)

This commit is contained in:
Daniel Marjamäki 2012-12-25 12:50:38 +01:00
parent 299c1bb208
commit db123c2c9b
2 changed files with 7 additions and 1 deletions

View File

@ -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));

View File

@ -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());
}
};