Fixed #9914 (False positive: knownArgument for 'x && false')
This commit is contained in:
parent
82047ea282
commit
5856fef83b
|
@ -3144,6 +3144,12 @@ void CheckOther::checkKnownArgument()
|
|||
}
|
||||
if (Token::simpleMatch(child->previous(), "sizeof ("))
|
||||
return ChildrenToVisit::none;
|
||||
if (Token::simpleMatch(child, "*") && (Token::simpleMatch(child->astOperand1(), "0") || Token::simpleMatch(child->astOperand2(), "0")))
|
||||
return ChildrenToVisit::none;
|
||||
if (Token::simpleMatch(child, "&&") && (Token::simpleMatch(child->astOperand1(), "false") || Token::simpleMatch(child->astOperand2(), "false")))
|
||||
return ChildrenToVisit::none;
|
||||
if (Token::simpleMatch(child, "||") && (Token::simpleMatch(child->astOperand1(), "true") || Token::simpleMatch(child->astOperand2(), "true")))
|
||||
return ChildrenToVisit::none;
|
||||
return ChildrenToVisit::op1_and_op2;
|
||||
});
|
||||
if (varexpr.empty())
|
||||
|
|
|
@ -8900,6 +8900,17 @@ private:
|
|||
" dostuff(self->maxsize * sizeof(intptr_t));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #9914 - zeroed expression
|
||||
check("void f(int x) {\n"
|
||||
" dostuff(x && false);\n"
|
||||
" dostuff(false && x);\n"
|
||||
" dostuff(x || true);\n"
|
||||
" dostuff(true || x);\n"
|
||||
" dostuff(x * 0);\n"
|
||||
" dostuff(0 * x);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkComparePointers() {
|
||||
|
|
Loading…
Reference in New Issue