Fixed #7975 (crash: Tokenizer::createLinks2 problem with enable_if<x&&y,C*>)

This commit is contained in:
Daniel Marjamäki 2017-04-03 21:48:22 +02:00
parent 79010eecea
commit 9c5a136f04
2 changed files with 14 additions and 1 deletions

View File

@ -3034,7 +3034,7 @@ void Tokenizer::createLinks2()
std::stack<Token*> type;
for (Token *token = list.front(); token; token = token->next()) {
if (Token::Match(token, "struct|class %name% [:<]"))
if (Token::Match(token, "%name%|> %name% [:<]"))
isStruct = true;
else if (Token::Match(token, "[;{}]"))
isStruct = false;

View File

@ -4569,6 +4569,19 @@ private:
ASSERT_EQUALS(true, tok1->link() == tok2);
ASSERT_EQUALS(true, tok2->link() == tok1);
}
{
// #7975
const char code[] = "template <class C> X<Y&&Z, C*> copy() {};\n";
errout.str("");
Tokenizer tokenizer(&settings0, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "< Y");
const Token *tok2 = Token::findsimplematch(tok1, "> copy");
ASSERT_EQUALS(true, tok1->link() == tok2);
ASSERT_EQUALS(true, tok2->link() == tok1);
}
}
void simplifyString() {