diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c2ecb907028..2e4662ea755 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 6eb47ec5f53..f7437cdf2e4 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3820,7 +3820,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "template \n" // #14612 - "void f(Fn && fn, Args&&... args) {\n" + "void f(Fn&& fn, Args&&... args) {\n" " static_assert(std::is_invocable_v);\n" "}\n"; SimpleTokenizer tokenizer(settingsDefault, *this); @@ -3830,6 +3830,19 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(true, tok1->link() == tok2); ASSERT_EQUALS(true, tok2->link() == tok1); } + + { + const char code[] = "template \n" // #14615 + "void f(Fn&& fn, Args&&... args) {\n" + " constexpr bool b{ std::is_invocable_v };\n" + "}\n"; + SimpleTokenizer tokenizer(settingsDefault, *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() {