diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 96b7c55c5..9d149c230 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -366,7 +366,7 @@ void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates() ; else if (level == 0 && Token::Match(tok2->previous(), "%type%")) { // @todo add better expression detection - if (!Token::Match(tok2->next(), "%type%|%num% ;")) + if (!Token::Match(tok2->next(), "*| %type%|%num% ;")) inclevel = true; } else if (tok2->next() && tok2->next()->isStandardType()) inclevel = true; diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 376ddc7e0..297b24de7 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -178,6 +178,7 @@ private: TEST_CASE(template138); TEST_CASE(template139); TEST_CASE(template140); + TEST_CASE(template141); // #9337 TEST_CASE(template_specialization_1); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_specialization_2); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template) @@ -3428,6 +3429,18 @@ private: } } + void template141() { // #9337 + const char code[] = "struct a {\n" + " int c;\n" + " template void d(b e) const { c < *e; }\n" + "};"; + const char exp[] = "struct a { " + "int c ; " + "template < typename b > void d ( b e ) const { c < * e ; } " + "} ;"; + ASSERT_EQUALS(exp, tok(code)); + } + void template_specialization_1() { // #7868 - template specialization template struct S> {..}; const char code[] = "template struct C {};\n" "template struct S {a};\n"