Fix issue 9361: false positive: (style) Condition 'isdigit(c)!=0' is always true (#2199)

This commit is contained in:
Paul Fultz II 2019-09-21 01:19:54 -05:00 committed by Daniel Marjamäki
parent 65d1e90aa3
commit 40f1635c35
2 changed files with 8 additions and 0 deletions

View File

@ -5239,6 +5239,7 @@ static bool evaluate(const Token *expr, const std::vector<std::list<ValueFlow::V
static std::list<ValueFlow::Value> getFunctionArgumentValues(const Token *argtok)
{
std::list<ValueFlow::Value> argvalues(argtok->values());
removeImpossible(argvalues);
if (argvalues.empty() && Token::Match(argtok, "%comp%|%oror%|&&|!")) {
argvalues.emplace_back(0);
argvalues.emplace_back(1);

View File

@ -3287,6 +3287,13 @@ private:
" bool compare = c == b;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #9361
check("void f(char c) {\n"
" if (c == '.') {}\n"
" else if (isdigit(c) != 0) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueContainer() {