diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7f4cd5584e8..e26bcb0c439 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -7612,8 +7612,6 @@ const ValueFlow::Value* ValueFlow::findValue(const std::list& if (ret) { if (ret->isInconclusive() && !settings.certainty.isEnabled(Certainty::inconclusive)) return nullptr; - if (ret->condition && !settings.severity.isEnabled(Severity::warning)) - return nullptr; } return ret; } diff --git a/test/testother.cpp b/test/testother.cpp index d6025e9a640..cbeca3ed72b 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -10603,6 +10603,13 @@ class TestOther : public TestFixture { " return f<-1>(2)\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + Settings settings = settingsBuilder(settings0).severity(Severity::portability).build(); + check("int f(int k, int& s) {\n" // #7215 + " if (k >= -128 && k <= 127)\n" + " s = (k << 8);\n" + "}\n", dinit(CheckOptions, $.settings = &settings)); + ASSERT_EQUALS("[test.cpp:2:11] -> [test.cpp:3:16]: (portability) Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]\n", errout_str()); } void checkNegativeShiftErrorPath() {