Fix issue 9361: false positive: (style) Condition 'isdigit(c)!=0' is always true (#2199)
This commit is contained in:
parent
65d1e90aa3
commit
40f1635c35
|
@ -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)
|
static std::list<ValueFlow::Value> getFunctionArgumentValues(const Token *argtok)
|
||||||
{
|
{
|
||||||
std::list<ValueFlow::Value> argvalues(argtok->values());
|
std::list<ValueFlow::Value> argvalues(argtok->values());
|
||||||
|
removeImpossible(argvalues);
|
||||||
if (argvalues.empty() && Token::Match(argtok, "%comp%|%oror%|&&|!")) {
|
if (argvalues.empty() && Token::Match(argtok, "%comp%|%oror%|&&|!")) {
|
||||||
argvalues.emplace_back(0);
|
argvalues.emplace_back(0);
|
||||||
argvalues.emplace_back(1);
|
argvalues.emplace_back(1);
|
||||||
|
|
|
@ -3287,6 +3287,13 @@ private:
|
||||||
" bool compare = c == b;\n"
|
" bool compare = c == b;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void alwaysTrueContainer() {
|
||||||
|
|
Loading…
Reference in New Issue