From 1d85a7887413f7353766a29fbe1ed56a8ec9361b Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Wed, 5 Sep 2018 14:10:56 +0200 Subject: [PATCH] Ticket #8654: Properly setup links for variadic template bases. (#1357) --- lib/tokenize.cpp | 1 + test/testtokenize.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5e2aa1f90..43731bc97 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3276,6 +3276,7 @@ void Tokenizer::createLinks2() continue; if (token->next() && !Token::Match(token->next(), "%name%|>|&|&&|*|::|,|(|)|{|}|;|[|:") && + !Token::simpleMatch(token->next(), ". . .") && !Token::Match(token->next(), "&& %name% =")) continue; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index c4476a287..94c01cbc0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4700,6 +4700,17 @@ private: ASSERT_EQUALS(true, tok1->link() == tok2); ASSERT_EQUALS(true, tok2->link() == tok1); } + { + // #8654 + const char code[] = "template struct A {}; " + "template struct foo : A... {};"; + errout.str(""); + Tokenizer tokenizer(&settings0, this); + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + const Token *A = Token::findsimplematch(tokenizer.tokens(), "A <"); + ASSERT_EQUALS(true, A->next()->link() == A->tokAt(3)); + } } void simplifyString() {