Fix 10543: FP knownConditionTrueFalse with static variable (#3491)
This commit is contained in:
parent
a1e0ef9b38
commit
bc90ae889d
|
@ -4378,6 +4378,13 @@ static void valueFlowSymbolic(TokenList* tokenlist, SymbolDatabase* symboldataba
|
||||||
} else if (isDifferentType(tok->astOperand2(), tok->astOperand1())) {
|
} else if (isDifferentType(tok->astOperand2(), tok->astOperand1())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const std::vector<const Variable*> 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);
|
Token* start = nextAfterAstRightmostLeaf(tok);
|
||||||
const Token* end = scope->bodyEnd;
|
const Token* end = scope->bodyEnd;
|
||||||
|
|
|
@ -3857,6 +3857,17 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void alwaysTrueInfer() {
|
||||||
|
|
Loading…
Reference in New Issue