Fixed #8115 (Tokenizer: links not properly set in r-value template 'Foo<int> && foo')

This commit is contained in:
Daniel Marjamäki 2017-07-09 13:26:59 +02:00
parent ea598d5284
commit dff9d13758
2 changed files with 14 additions and 1 deletions

View File

@ -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;

View File

@ -4616,6 +4616,19 @@ private:
ASSERT_EQUALS(true, tok1->link() == tok2);
ASSERT_EQUALS(true, tok2->link() == tok1);
}
{
// #8115
const char code[] = "void Test(C<int> && 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() {