Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Aug 23, 2023
1 parent 41da316 commit e7535fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ bool isUsedAsBool(const Token* const tok, const Settings* settings)
return isUsedAsBool(parent);
if (parent->isUnaryOp("*"))
return isUsedAsBool(parent);
if (Token::Match(parent, "==|!=") && (tok->astSibling()->isNumber() || tok->astSibling()->isLiteral()) && tok->astSibling()->hasKnownIntValue() &&
if (Token::Match(parent, "==|!=") && (tok->astSibling()->isNumber() || tok->astSibling()->isKeyword()) && tok->astSibling()->hasKnownIntValue() &&
tok->astSibling()->values().front().intvalue == 0)
return true;
if (parent->str() == "(" && astIsRHS(tok) && Token::Match(parent->astOperand1(), "if|while"))
Expand Down
2 changes: 1 addition & 1 deletion test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3555,7 +3555,7 @@ class TestCondition : public TestFixture {
" if (handle) return 1;\n"
" else return 0;\n"
"}");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Identical condition 'handle!=0', second condition is always false\n", errout.str());
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Identical condition 'handle!=nullptr', second condition is always false\n", errout.str());

check("void f(void* x, void* y) {\n"
" if (x == nullptr && y == nullptr)\n"
Expand Down

0 comments on commit e7535fd

Please sign in to comment.