Skip to content

Commit d588469

Browse files
committed
Fixed #7363 (valueflowOppositeCondition - if (size1 > size2) ... else if (size1 < size2) ...)
1 parent 3b046b4 commit d588469

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/valueflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static void valueFlowOppositeCondition(SymbolDatabase *symboldatabase, const Set
733733
const Token *cond2 = tok2->tokAt(4)->astOperand2();
734734
if (!cond2 || !cond2->isComparisonOp())
735735
continue;
736-
if (isOppositeCond(false, cpp, cond1, cond2, settings->library.functionpure)) {
736+
if (isOppositeCond(true, cpp, cond1, cond2, settings->library.functionpure)) {
737737
ValueFlow::Value value(1);
738738
value.setKnown();
739739
setTokenValue(const_cast<Token*>(cond2), value);

test/testvalueflow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,12 @@ class TestValueFlow : public TestFixture {
18971897
ASSERT_EQUALS(1, value.intvalue);
18981898
ASSERT(value.isKnown());
18991899

1900+
code = "int f(int x) {\n"
1901+
" if (x < 2) {}\n"
1902+
" else if (x > 2) {}\n" // <- possible value
1903+
"}";
1904+
ASSERT(isNotKnownValues(code, ">"));
1905+
19001906
// function
19011907
code = "int f(int x) { return x + 1; }\n" // <- possible value
19021908
"void a() { f(12); }\b";

0 commit comments

Comments
 (0)