This commit is contained in:
parent
86782af43c
commit
d206047b84
|
@ -121,8 +121,11 @@ const Token * astIsVariableComparison(const Token *tok, const std::string &comp,
|
|||
} else if (comp == "!=" && rhs == std::string("0")) {
|
||||
ret = tok;
|
||||
} else if (comp == "==" && rhs == std::string("0")) {
|
||||
if (tok->str() == "!")
|
||||
if (tok->str() == "!") {
|
||||
ret = tok->astOperand1();
|
||||
// handle (!(x!=0)) as (x==0)
|
||||
astIsVariableComparison(ret, "!=", "0", &ret);
|
||||
}
|
||||
}
|
||||
while (ret && ret->str() == ".")
|
||||
ret = ret->astOperand2();
|
||||
|
|
|
@ -98,6 +98,7 @@ private:
|
|||
TEST_CASE(ifelse7); // #5576 - if (fd < 0)
|
||||
TEST_CASE(ifelse8); // #5747 - if (fd == -1)
|
||||
TEST_CASE(ifelse9); // #5273 - if (X(p==NULL, 0))
|
||||
TEST_CASE(ifelse10); // #8794 - if (!(x!=NULL))
|
||||
|
||||
// switch
|
||||
TEST_CASE(switch1);
|
||||
|
@ -1150,6 +1151,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void ifelse10() { // #8794
|
||||
check("void f() {\n"
|
||||
" void *x = malloc(1U);\n"
|
||||
" if (!(x != NULL))\n"
|
||||
" return;\n"
|
||||
" free(x);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void switch1() {
|
||||
check("void f() {\n"
|
||||
" char *p = 0;\n"
|
||||
|
|
Loading…
Reference in New Issue