Fixed createLinks2() when inheriting from a template (#6601)

This commit is contained in:
PKEuS 2015-11-06 10:44:37 +01:00
parent eb2b0fa0d0
commit 62bc827eb0
2 changed files with 19 additions and 1 deletions

View File

@ -3025,7 +3025,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

@ -4489,6 +4489,24 @@ private:
ASSERT_EQUALS(true, tok->linkAt(3) == nullptr);
}
{
// #6601
const char code[] = "template<class R> struct FuncType<R(&)()> : FuncType<R()> { };";
errout.str("");
Tokenizer tokenizer(&settings0, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
const Token *tok = tokenizer.tokens();
ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(4)); // <class R>
ASSERT_EQUALS(true, tok->linkAt(7) == tok->tokAt(14)); // <R(&)()>
ASSERT_EQUALS(true, tok->linkAt(9) == tok->tokAt(11)); // (&)
ASSERT_EQUALS(true, tok->linkAt(12) == tok->tokAt(13)); // ()
ASSERT_EQUALS(true, tok->linkAt(17) == tok->tokAt(21)); // <R()>
ASSERT_EQUALS(true, tok->linkAt(19) == tok->tokAt(20)); // ()
ASSERT_EQUALS(true, tok->linkAt(22) == tok->tokAt(23)); // {}
}
}
void simplifyString() {