Fix #11862 FP truncLongCastAssignment with increment (#5290)

This commit is contained in:
chrchr-github 2023-08-03 13:49:11 +02:00 committed by GitHub
parent da6c39e971
commit 5ff8955dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -317,7 +317,7 @@ void CheckType::checkLongCast()
// Assignments..
for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) {
if (tok->str() != "=" || !Token::Match(tok->astOperand2(), "*|<<"))
if (tok->str() != "=" || !Token::Match(tok->astOperand2(), "*|<<") || tok->astOperand2()->isUnaryOp("*"))
continue;
if (tok->astOperand2()->hasKnownIntValue()) {

View File

@ -367,6 +367,11 @@ private:
"}\n", settings);
ASSERT_EQUALS("[test.cpp:2]: (style) float result is returned as double value. If the return value is double to avoid loss of information, then you have loss of information.\n",
errout.str());
check("void f(int* p) {\n" // #11862
" long long j = *(p++);\n"
"}\n", settings);
ASSERT_EQUALS("", errout.str());
}
void longCastReturn() {