Fix issue 9362: FP: (style) Condition '(v&1)==0' is always false (#2200)
This commit is contained in:
parent
da91c139d5
commit
c1961cec1c
|
@ -770,6 +770,10 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
|
|||
if (parent->isComparisonOp() && value.isImpossible())
|
||||
return;
|
||||
|
||||
// Skip operators with impossible values that are not invertible
|
||||
if (Token::Match(parent, "%|/|&|%or%") && value.isImpossible())
|
||||
return;
|
||||
|
||||
// known result when a operand is 0.
|
||||
if (Token::Match(parent, "[&*]") && value.isKnown() && value.isIntValue() && value.intvalue==0) {
|
||||
setTokenValue(parent, value, settings);
|
||||
|
|
|
@ -3294,6 +3294,16 @@ private:
|
|||
" else if (isdigit(c) != 0) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #9362
|
||||
check("uint8_t g();\n"
|
||||
"void f() {\n"
|
||||
" const uint8_t v = g();\n"
|
||||
" if((v != 0x00)) {\n"
|
||||
" if( (v & 0x01) == 0x00) {}\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueContainer() {
|
||||
|
|
Loading…
Reference in New Issue