Skip to content

Commit 87ac6b3

Browse files
Update astutils.cpp
1 parent 4aa87ff commit 87ac6b3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/astutils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,8 @@ static const Token * followVariableExpression(const Settings& settings, const To
12121212
const Token * lastTok = precedes(tok, end) ? end : tok;
12131213
// If this is in a loop then check if variables are modified in the entire scope
12141214
const Token * endToken = (isInLoopCondition(tok) || isInLoopCondition(varTok) || var->scope() != tok->scope()) ? var->scope()->bodyEnd : lastTok;
1215-
if (!var->isConst() && (!precedes(varTok, endToken) || isVariableChanged(varTok, endToken, tok->varId(), false, settings)))
1215+
const int indirect = var->isArray() ? var->dimensions().size() : 0;
1216+
if (!var->isConst() && (!precedes(varTok, endToken) || isVariableChanged(varTok, endToken, indirect, tok->varId(), false, settings)))
12161217
return tok;
12171218
if (precedes(varTok, endToken) && isAliased(varTok, endToken, tok->varId()))
12181219
return tok;

0 commit comments

Comments
 (0)