Fixed #7158 (Tokenizer::createLinks2(): does not set links for < > in 'enum { value = boost::mpl::at_c<B,C> };')

This commit is contained in:
Daniel Marjamäki 2016-08-01 22:26:11 +02:00
parent e784901303
commit 31484133c0
2 changed files with 15 additions and 1 deletions

View File

@ -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<b>[" is expected

View File

@ -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<B, 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);