diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 096e3d56f56..1b5c0508162 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1107,19 +1107,6 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett for (const Token* tok2 : tokens) { if (const ValueFlow::Value* v = tok2->getKnownValue(ValueFlow::Value::ValueType::INT)) { values.emplace_back(*v); - } else { - ValueFlow::Value symValue{}; - symValue.valueType = ValueFlow::Value::ValueType::SYMBOLIC; - symValue.tokvalue = tok2; - values.push_back(std::move(symValue)); - std::copy_if(tok2->values().cbegin(), - tok2->values().cend(), - std::back_inserter(values), - [](const ValueFlow::Value& v) { - if (!v.isKnown()) - return false; - return v.isSymbolicValue(); - }); } } const bool isMin = Token::Match(condTok, "<|<=") ^ flipped; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index da4ecae43b3..8c1779cf106 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -5222,6 +5222,12 @@ class TestCondition : public TestFixture { " if (c) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f(int a, int b) {\n" // #11437 + " a = a < b ? b : a;\n" + " if (a != b) {}\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void alwaysTrueInfer() { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index abeb603b660..1451de322ea 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -166,7 +166,6 @@ class TestValueFlow : public TestFixture { TEST_CASE(valueFlowSymbolicIdentity); TEST_CASE(valueFlowSymbolicStrlen); TEST_CASE(valueFlowSmartPointer); - TEST_CASE(valueFlowImpossibleMinMax); TEST_CASE(valueFlowImpossibleIncDec); TEST_CASE(valueFlowImpossibleUnknownConstant); TEST_CASE(valueFlowContainerEqual); @@ -9334,67 +9333,6 @@ class TestValueFlow : public TestFixture { ASSERT_EQUALS(false, testValueOfX(code, 5U, 0)); } - void valueFlowImpossibleMinMax() - { - const char* code; - - code = "void f(int a, int b) {\n" - " int x = a < b ? a : b;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", 1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "b", 1)); - - code = "void f(int a, int b) {\n" - " int x = a > b ? a : b;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", -1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "b", -1)); - - code = "void f(int a, int b) {\n" - " int x = a > b ? b : a;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", 1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "b", 1)); - - code = "void f(int a, int b) {\n" - " int x = a < b ? b : a;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", -1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "b", -1)); - - code = "void f(int a) {\n" - " int x = a < 0 ? a : 0;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", 1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, 1)); - - code = "void f(int a) {\n" - " int x = a > 0 ? a : 0;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", -1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, -1)); - - code = "void f(int a) {\n" - " int x = a > 0 ? 0 : a;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", 1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, 1)); - - code = "void f(int a) {\n" - " int x = a < 0 ? 0 : a;\n" - " return x;\n" - "}\n"; - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, "a", -1)); - ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, -1)); - } - void valueFlowImpossibleIncDec() { const char* code;