diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 6f2a2defe..0dcd77418 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -2574,7 +2574,7 @@ struct SingleValueFlowForwardAnalyzer : ValueFlowForwardAnalyzer { virtual bool isGlobal() const OVERRIDE { for (const auto&p:getVars()) { const Variable* var = p.second; - if (var->isGlobal() && !var->isConst()) + if (!var->isLocal() && !var->isArgument() && !var->isConst()) return true; } return false; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 871e93c5a..b641a7ec0 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3588,6 +3588,17 @@ private: " return;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("struct A {\n" + " std::vector v;\n" + " void g();\n" + " void f(bool b) {\n" + " v.clear();\n" + " g();\n" + " return !v.empty();\n" + " }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void multiConditionAlwaysTrue() {