diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index bfb2a361e..1ceda3ce7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3847,7 +3847,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), ";|}|{"))) @@ -3871,7 +3871,7 @@ void Tokenizer::createLinks2() if (token->str() == ">>") continue; if (token->next() && - !Token::Match(token->next(), "%name%|%comp%|&|&&|*|::|,|(|)|{|}|;|[|:") && + !Token::Match(token->next(), "%name%|%comp%|&|&&|*|::|,|(|)|{|}|;|[|:|.") && !Token::simpleMatch(token->next(), ". . .") && !Token::Match(token->next(), "&& %name% =")) continue; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7d5a976b9..02fe3f871 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4873,6 +4873,25 @@ private: tokenizer.tokenize(istr, "test.cpp"); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ==")->link()); } + + { + // #9145 + const char code[] = "template struct b {\n" + " template constexpr void operator()(c &&) const;\n" + "};\n" + "template struct e { b f; };\n" + "template using h = e;\n" + "template h i;\n" + "template \n" + "template \n" + "constexpr void b::operator()(c &&) const {\n" + " i<3>.f([] {});\n" + "}\n"; + Tokenizer tokenizer(&settings0, this); + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> . f (")->link()); + } } void simplifyString() {