diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a371df76e5d..20e3c6231f5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5544,7 +5544,7 @@ void Tokenizer::createLinks2() while (!type.empty() && type.top()->str() == "<") { const Token* end = type.top()->findClosingBracket(); - if (Token::Match(end, "> %comp%|;|.|=|{|(|::")) + if (Token::Match(end, "> %comp%|;|.|=|{|(|)|::")) break; // Variable declaration if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{"))) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 16c9335dce7..dea8d08e57f 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3829,6 +3829,19 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(true, tok1->link() == tok2); ASSERT_EQUALS(true, tok2->link() == tok1); } + + { + const char code[] = "template \n" // #14612 + "void f(Fn && fn, Args&&... args) {\n" + " static_assert(std::is_invocable_v);\n" + "}\n"; + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); + const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< Fn"); + const Token* tok2 = Token::findsimplematch(tok1, "> )"); + ASSERT_EQUALS(true, tok1->link() == tok2); + ASSERT_EQUALS(true, tok2->link() == tok1); + } } void simplifyString() {