Skip to content

Commit 5ff2bec

Browse files
committed
handle templated return types
1 parent eb4a341 commit 5ff2bec

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6568,12 +6568,23 @@ void Tokenizer::simplifyHeadersAndUnusedTemplates()
65686568
} else {
65696569
Token *funcTok = closingBracket->next();
65706570
while (funcTok) {
6571-
if (Token::Match(funcTok, "constexpr|static|inline|const|%type%|&|&&|*") && !Token::Match(funcTok, "%name% (")) {
6571+
if (Token::Match(funcTok, "::|constexpr|static|inline|const|%type%|&|&&|*") && !Token::Match(funcTok, "%name% (")) {
65726572
funcTok = funcTok->next();
65736573
continue;
65746574
}
6575+
if (Token::simpleMatch(funcTok, "<")) {
6576+
funcTok = funcTok->findClosingBracket();
6577+
if (funcTok) {
6578+
funcTok = funcTok->next();
6579+
} else {
6580+
break;
6581+
}
6582+
continue;
6583+
}
65756584
break;
65766585
}
6586+
if (!funcTok)
6587+
break;
65776588
if (!Token::Match(funcTok, "%name% (")) {
65786589
tok = funcTok;
65796590
continue;

test/cli/other_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,6 +3479,12 @@ class S {
34793479
}
34803480
};
34813481
3482+
template<typename T>
3483+
std::vector<T> f_t_13() {
3484+
(void)(*((int*)0));
3485+
return {};
3486+
}
3487+
34823488
void f() {}
34833489
""")
34843490

0 commit comments

Comments
 (0)