From 31484133c01a8e77242ad638f813e7c671a5dcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 1 Aug 2016 22:26:11 +0200 Subject: [PATCH] Fixed #7158 (Tokenizer::createLinks2(): does not set links for < > in 'enum { value = boost::mpl::at_c };') --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index bedf86531..116389919 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3049,7 +3049,7 @@ void Tokenizer::createLinks2() } else if (token->str() == ">") { if (type.empty() || type.top()->str() != "<") // < and > don't match. continue; - if (token->next() && !Token::Match(token->next(), "%name%|>|&|*|::|,|(|)|{|;|[|:")) + if (token->next() && !Token::Match(token->next(), "%name%|>|&|*|::|,|(|)|{|}|;|[|:")) continue; // if > is followed by [ .. "new a[" is expected diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 2e940887b..366dfaf34 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -292,6 +292,7 @@ private: TEST_CASE(simplifyStdType); // #4947, #4950, #4951 TEST_CASE(createLinks); + TEST_CASE(createLinks2); TEST_CASE(signed1); TEST_CASE(simplifyString); @@ -4523,6 +4524,19 @@ private: } } + void createLinks2() { + { // #7158 + const char code[] = "enum { value = boost::mpl::at_c };"; + errout.str(""); + Tokenizer tokenizer(&settings0, this); + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + const Token *tok = Token::findsimplematch(tokenizer.tokens(), "<"); + ASSERT_EQUALS(true, tok->link() == tok->tokAt(4)); + ASSERT_EQUALS(true, tok->linkAt(4) == tok); + } + } + void simplifyString() { errout.str(""); Tokenizer tokenizer(&settings0, this);