diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 5b10539e9..02a6bc79f 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -312,14 +312,15 @@ void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates() break; // template variable or type.. - if (Token::Match(tok, "%type% <")) { + if (Token::Match(tok, "%type% <") && !Token::simpleMatch(tok, "template")) { // these are used types.. std::set usedtypes; // parse this statement and see if the '<' and '>' are matching unsigned int level = 0; for (const Token *tok2 = tok; tok2 && !Token::simpleMatch(tok2, ";"); tok2 = tok2->next()) { - if (Token::simpleMatch(tok2, "{") && (!Token::Match(tok2->previous(), ">|%type%") || Token::simpleMatch(tok2->link(), "} ;"))) + if (Token::simpleMatch(tok2, "{") && + (!Token::Match(tok2->previous(), ">|%type%") || Token::simpleMatch(tok2->link(), "} ;"))) break; if (tok2->str() == "(") tok2 = tok2->link(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 09380a426..7308d292c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6569,6 +6569,17 @@ private: // #10139 ASSERT_NO_THROW(tokenizeAndStringify("template\n" "void foo(std::enable_if_t>* = 0) {}\n")); + + // #10001 + ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n" + " int c;\n" + " template void d(b e) const { c < e ? c : e; }\n" + "};\n")); + + ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n" + " int c;\n" + " template void d(b e) const { c > e ? c : e; }\n" + "};\n")); } void checkTemplates() {