Skip to content

Commit 0a6633e

Browse files
committed
fix
1 parent 713c70c commit 0a6633e

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

lib/checkother.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,8 +1591,23 @@ void CheckOther::checkPassByReference()
15911591
if (var->isArray() && (!var->isStlType() || Token::simpleMatch(var->nameToken()->next(), "[")))
15921592
continue;
15931593

1594+
bool argWithNoBody = false;
1595+
if (var->isArgument()) {
1596+
const Token *tok = var->nameToken();
1597+
for (; tok; tok = tok->next()) {
1598+
if (Token::simpleMatch(tok, "(")) {
1599+
tok = tok->link();
1600+
continue;
1601+
}
1602+
if (Token::simpleMatch(tok, ")"))
1603+
break;
1604+
}
1605+
1606+
argWithNoBody = Token::simpleMatch(tok, ") ;");
1607+
}
1608+
15941609
const bool isConst = var->isConst();
1595-
if (isConst) {
1610+
if (isConst && !argWithNoBody) {
15961611
passedByValueError(var, inconclusive, isRangeBasedFor);
15971612
continue;
15981613
}

0 commit comments

Comments
 (0)