From bbe8667abec35b9a4b789ea6d27483a8f93283a5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:31:32 +0200 Subject: [PATCH] Update checkother.cpp --- lib/checkother.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index e4fcfa73c16..c8f26b37e78 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -915,6 +915,10 @@ static bool isSimpleExpr(const Token* tok, const Variable* var, const Settings* if (Token::Match(ftok, "%name% (") && ((ftok->function() && ftok->function()->isConst()) || settings->library.isFunctionConst(ftok->str(), /*pure*/ true))) needsCheck = true; + if (tok->isArithmeticalOp() && + (!tok->astOperand1() || isSimpleExpr(tok->astOperand1(), var, settings)) && + (!tok->astOperand2() || isSimpleExpr(tok->astOperand2(), var, settings))) + return true; } return (needsCheck && !findExpressionChanged(tok, tok->astParent(), var->scope()->bodyEnd, settings)); }