diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 2c1bdf8cf..f7ec6b3f5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4554,7 +4554,8 @@ void Tokenizer::createLinks2() } } else { type.pop(); - if (Token::Match(token, "> %name%") && Token::Match(top1->tokAt(-2), "%op% %name% <") && + if (Token::Match(token, "> %name%") && !token->next()->isKeyword() && + Token::Match(top1->tokAt(-2), "%op% %name% <") && (templateTokens.empty() || top1 != templateTokens.top())) continue; Token::createMutualLinks(top1, token); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index fc929a033..3f3907301 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3375,6 +3375,19 @@ private: ASSERT_EQUALS(true, tok1->link() == tok2); ASSERT_EQUALS(true, tok2->link() == tok1); } + + { + // #10664 + const char code[] = "class C1 : public T1const> {};\n"; + errout.str(""); + Tokenizer tokenizer(&settings0, this); + std::istringstream istr(code); + ASSERT(tokenizer.tokenize(istr, "test.cpp")); + const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< C2"); + const Token* tok2 = Token::findsimplematch(tok1, "> const"); + ASSERT_EQUALS(true, tok1->link() == tok2); + ASSERT_EQUALS(true, tok2->link() == tok1); + } } void simplifyString() {