We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 713c70c commit 0a6633eCopy full SHA for 0a6633e
1 file changed
lib/checkother.cpp
@@ -1591,8 +1591,23 @@ void CheckOther::checkPassByReference()
1591
if (var->isArray() && (!var->isStlType() || Token::simpleMatch(var->nameToken()->next(), "[")))
1592
continue;
1593
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
1609
const bool isConst = var->isConst();
- if (isConst) {
1610
+ if (isConst && !argWithNoBody) {
1611
passedByValueError(var, inconclusive, isRangeBasedFor);
1612
1613
}
0 commit comments