Skip to content

Commit 97146ef

Browse files
committed
fix
1 parent db70fde commit 97146ef

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
@@ -1680,6 +1680,27 @@ void CheckUnusedVarImpl::checkStructMemberUsage()
16801680
if (use)
16811681
break;
16821682
}
1683+
// Class used in template with unknown definition
1684+
if (Token::Match(tok, "%name% <") && tok->linkAt(1)) {
1685+
if (tok->function())
1686+
continue;
1687+
if (tok->type() && tok->type()->classScope)
1688+
continue;
1689+
const Token *start = tok;
1690+
while (Token::Match(start->previous(), "%name%|::"))
1691+
start = start->previous();
1692+
if (mSettings.library.detectContainer(start))
1693+
continue;
1694+
const Token *end = tok->linkAt(1);
1695+
for (; tok != end; tok = tok->next()) {
1696+
if (tok->type() && tok->type()->classScope == &scope) {
1697+
use = true;
1698+
break;
1699+
}
1700+
}
1701+
if (use)
1702+
break;
1703+
}
16831704
if (tok->variable() != &var)
16841705
continue;
16851706
if (tok != var.nameToken()) {

0 commit comments

Comments
 (0)