Fix issue 8932: False positive knownConditionTrueFalse - valueflow ignores operator < (#1584)
This commit is contained in:
parent
400c6c8e76
commit
5fa956a597
|
@ -1153,7 +1153,7 @@ static void valueFlowSameExpressions(TokenList *tokenlist)
|
|||
if (tok->astOperand1()->isLiteral() || tok->astOperand2()->isLiteral())
|
||||
continue;
|
||||
|
||||
if (astIsFloat(tok->astOperand1(), true) || astIsFloat(tok->astOperand2(), true))
|
||||
if (!astIsIntegral(tok->astOperand1(), false) && !astIsIntegral(tok->astOperand2(), false))
|
||||
continue;
|
||||
|
||||
ValueFlow::Value val;
|
||||
|
|
|
@ -2774,6 +2774,17 @@ private:
|
|||
|
||||
check("void f(const int a[]){ if (a == 0){} }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct S {\n"
|
||||
" bool operator<(const S&);\n"
|
||||
"};\n"
|
||||
"int main() {\n"
|
||||
" S s;\n"
|
||||
" bool c = s<s;\n"
|
||||
" if (c) return 0;\n"
|
||||
" else return 42;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void multiConditionAlwaysTrue() {
|
||||
|
|
Loading…
Reference in New Issue