Skip to content

Commit 4698f3b

Browse files
committed
fix
1 parent 790c12c commit 4698f3b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

lib/checkunusedvar.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,27 @@ void CheckUnusedVarImpl::checkStructMemberUsage()
16761676
if (use)
16771677
break;
16781678
}
1679+
// Class used in template with unknown definition
1680+
if (Token::Match(tok, "%name% <") && tok->linkAt(1)) {
1681+
if (tok->function())
1682+
continue;
1683+
if (tok->type() && tok->type()->classScope)
1684+
continue;
1685+
const Token *start = tok;
1686+
while (Token::Match(start->tokAt(-2), "%name% ::"))
1687+
start = start->tokAt(-2);
1688+
if (mSettings.library.detectContainer(start))
1689+
continue;
1690+
const Token *end = tok->linkAt(1);
1691+
for (; tok != end; tok = tok->next()) {
1692+
if (tok->type() && tok->type()->classScope == &scope) {
1693+
use = true;
1694+
break;
1695+
}
1696+
}
1697+
if (use)
1698+
break;
1699+
}
16791700
if (tok->variable() != &var)
16801701
continue;
16811702
if (tok != var.nameToken()) {

0 commit comments

Comments
 (0)