Fix crash in TemplateSimplifier::TokenAndName::TokenAndName in case of template constexpr (#1748)

This is not propper solution. This change just eliminates crash and logs error.

https://trac.cppcheck.net/ticket/9046
This commit is contained in:
Pavol Misik 2019-03-23 10:42:41 +01:00 committed by Daniel Marjamäki
parent a135683d2f
commit 7c7ee66cf9
1 changed files with 7 additions and 2 deletions

View File

@ -83,8 +83,13 @@ TemplateSimplifier::TokenAndName::TokenAndName(Token *tok, const std::string &s,
isAlias(paramEnd->strAt(1) == "using");
isClass(Token::Match(paramEnd->next(), "class|struct|union %name% <|{|:|;"));
const Token *tok1 = nameToken->next();
if (tok1->str() == "<")
tok1 = tok1->findClosingBracket()->next();
if (tok1->str() == "<") {
const Token *closing = tok1->findClosingBracket();
if (closing)
tok1 = closing->next();
else
throw InternalError(tok, "unsupported syntax", InternalError::SYNTAX);
}
isFunction(tok1->str() == "(");
isVariable(!isClass() && Token::Match(tok1, "=|;"));
if (isVariable())