diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b22658db28c..19970e19a4b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5647,6 +5647,8 @@ void Tokenizer::createLinks2() const Token* end = type.top()->findClosingBracket(); if (Token::Match(end, "> %comp%|;|.|=|{|}|(|)|::")) break; + if (Token::Match(end, "> %name% (|::")) + break; // Variable declaration if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{"))) break; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 600d457e944..95f2ac8e8a4 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3933,6 +3933,21 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(true, tok1->link() == tok2); ASSERT_EQUALS(true, tok2->link() == tok1); } + + { + const char code[] = "std::enable_if_t<0 || 1, void> f() {}\n" // #14982 + "std::enable_if_t<0 || 1, void> S::g() {}\n"; + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT(tokenizer.tokenize(code)); + const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< 0"); + const Token* tok2 = Token::findsimplematch(tok1, "> f"); + ASSERT_EQUALS(true, tok1->link() == tok2); + ASSERT_EQUALS(true, tok2->link() == tok1); + const Token* tok3 = Token::findsimplematch(tok2, "< 0"); + const Token* tok4 = Token::findsimplematch(tok3, "> S"); + ASSERT_EQUALS(true, tok3->link() == tok4); + ASSERT_EQUALS(true, tok4->link() == tok3); + } } void simplifyString() {