diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d7b203a0c..42191c715 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3071,7 +3071,7 @@ void Tokenizer::createLinks2() if (type.empty() || type.top()->str() != "<") // < and > don't match. continue; if (token->next() && - !Token::Match(token->next(), "%name%|>|&|*|::|,|(|)|{|}|;|[|:") && + !Token::Match(token->next(), "%name%|>|&|&&|*|::|,|(|)|{|}|;|[|:") && !Token::Match(token->next(), "&& %name% =")) continue; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 061264775..0291a3285 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4616,6 +4616,19 @@ private: ASSERT_EQUALS(true, tok1->link() == tok2); ASSERT_EQUALS(true, tok2->link() == tok1); } + + { + // #8115 + const char code[] = "void Test(C && c);"; + errout.str(""); + Tokenizer tokenizer(&settings0, this); + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "<"); + const Token *tok2 = tok1->tokAt(2); + ASSERT_EQUALS(true, tok1->link() == tok2); + ASSERT_EQUALS(true, tok2->link() == tok1); + } } void simplifyString() {