Skip to content

Commit b16ad3e

Browse files
committed
fix
1 parent 827d417 commit b16ad3e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

lib/checkunusedvar.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,29 @@ void CheckUnusedVarImpl::checkStructMemberUsage()
16801680
if (use)
16811681
break;
16821682
}
1683+
// Class used in template with unknown definition
1684+
if (Token::Match(tok, "%name% <") && tok->next()->link()) {
1685+
if (tok->function())
1686+
continue;
1687+
if (tok->type() && tok->type()->classScope)
1688+
continue;
1689+
{
1690+
const Token *start = tok;
1691+
while (Token::Match(start->previous(), "%name%|::"))
1692+
start = start->previous();
1693+
if (mSettings.library.detectContainer(start))
1694+
continue;
1695+
}
1696+
const Token *end = tok->next()->link();
1697+
for (; tok != end; tok = tok->next()) {
1698+
if (tok->type() && tok->type()->classScope == &scope) {
1699+
use = true;
1700+
break;
1701+
}
1702+
}
1703+
if (use)
1704+
break;
1705+
}
16831706
if (tok->variable() != &var)
16841707
continue;
16851708
if (tok != var.nameToken()) {

0 commit comments

Comments
 (0)