Skip to content

Commit 3cf97d0

Browse files
committed
Handle scoped function
1 parent e69733b commit 3cf97d0

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5647,7 +5647,7 @@ void Tokenizer::createLinks2()
56475647
const Token* end = type.top()->findClosingBracket();
56485648
if (Token::Match(end, "> %comp%|;|.|=|{|}|(|)|::"))
56495649
break;
5650-
if (Token::Match(end, "> %name% ("))
5650+
if (Token::Match(end, "> %name% (|::"))
56515651
break;
56525652
// Variable declaration
56535653
if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{")))

test/testtokenize.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3935,13 +3935,18 @@ class TestTokenizer : public TestFixture {
39353935
}
39363936

39373937
{
3938-
const char code[] = "std::enable_if_t<0 || 1, void> f() {}\n"; // #14982
3938+
const char code[] = "std::enable_if_t<0 || 1, void> f() {}\n" // #14982
3939+
"std::enable_if_t<0 || 1, void> S::g() {}\n";
39393940
SimpleTokenizer tokenizer(settingsDefault, *this);
39403941
ASSERT(tokenizer.tokenize(code));
39413942
const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< 0");
39423943
const Token* tok2 = Token::findsimplematch(tok1, "> f");
39433944
ASSERT_EQUALS(true, tok1->link() == tok2);
39443945
ASSERT_EQUALS(true, tok2->link() == tok1);
3946+
const Token* tok3 = Token::findsimplematch(tok2, "< 0");
3947+
const Token* tok4 = Token::findsimplematch(tok3, "> S");
3948+
ASSERT_EQUALS(true, tok3->link() == tok4);
3949+
ASSERT_EQUALS(true, tok4->link() == tok3);
39453950
}
39463951
}
39473952

0 commit comments

Comments
 (0)