Fixed #8851 (Crash in valueFlowContainerForward (daca@home: pbbam))

This commit is contained in:
Daniel Marjamäki 2018-11-18 20:18:55 +01:00
parent 5eddcb0827
commit 9ef3c79bc6
2 changed files with 14 additions and 2 deletions

View File

@ -3244,10 +3244,12 @@ void Tokenizer::createLinks2()
if (Token::Match(token, "{|[|(")) if (Token::Match(token, "{|[|("))
type.push(token); type.push(token);
else if (!type.empty() && Token::Match(token, "}|]|)")) { else if (!type.empty() && Token::Match(token, "}|]|)")) {
while (type.top()->str() == "<") while (type.top()->str() == "<") {
type.pop(); if (templateToken && templateToken->next() == type.top())
type.pop();
templateToken = nullptr; templateToken = nullptr;
type.pop();
}
type.pop();
} else } else
token->link(nullptr); token->link(nullptr);
} else if (!templateToken && !isStruct && Token::Match(token, "%oror%|&&|;")) { } else if (!templateToken && !isStruct && Token::Match(token, "%oror%|&&|;")) {

View File

@ -4716,6 +4716,16 @@ private:
const Token *A = Token::findsimplematch(tokenizer.tokens(), "A <"); const Token *A = Token::findsimplematch(tokenizer.tokens(), "A <");
ASSERT_EQUALS(true, A->next()->link() == A->tokAt(3)); ASSERT_EQUALS(true, A->next()->link() == A->tokAt(3));
} }
{
// #8851
const char code[] = "template<typename std::enable_if<!(std::value1) && std::value2>::type>"
"void basic_json() {}";
errout.str("");
Tokenizer tokenizer(&settings0, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
ASSERT_EQUALS(true, Token::simpleMatch(tokenizer.tokens()->next()->link(), "> void"));
}
} }
void simplifyString() { void simplifyString() {