diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index cef8e3b2f..8b226886e 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -470,14 +470,14 @@ std::list TemplateSimplifier::getTemplateDeclarations(Token *tokens, bo tok = tok->linkAt(2); if (Token::simpleMatch(tok, "template <")) { - Token *parmEnd = tok->next()->findClosingBracket(); + // Some syntax checks, see #6865 if (!tok->tokAt(2)) syntaxError(tok->next()); - if (tok->tokAt(2)->str()=="typename" && + if (tok->strAt(2)=="typename" && (!tok->tokAt(3) || !Token::Match(tok->tokAt(3), "%name%|."))) syntaxError(tok->next()); codeWithTemplates = true; - + Token *parmEnd = tok->next()->findClosingBracket(); int indentlevel = 0; for (const Token *tok2 = parmEnd; tok2; tok2 = tok2->next()) { if (tok2->str() == "(")