diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 8fc60108c..3b80b934f 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4378,6 +4378,13 @@ static void valueFlowSymbolic(TokenList* tokenlist, SymbolDatabase* symboldataba } else if (isDifferentType(tok->astOperand2(), tok->astOperand1())) { continue; } + const std::vector vars = getLHSVariables(tok); + if (std::any_of(vars.begin(), vars.end(), [](const Variable* var) { + if (var->isLocal()) + return var->isStatic(); + return !var->isArgument(); + })) + continue; Token* start = nextAfterAstRightmostLeaf(tok); const Token* end = scope->bodyEnd; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 8ab8fe07c..4c1843f79 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3857,6 +3857,17 @@ private: " }\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("int get_delta() {\n" + " clock_t now_ms = (clock() / (CLOCKS_PER_SEC / 1000));\n" + " static clock_t last_clock_ms = now_ms;\n" + " clock_t delta = now_ms - last_clock_ms;\n" + " last_clock_ms = now_ms;\n" + " if (delta > 50)\n" + " delta = 50;\n" + " return delta;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueInfer() {