diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 13fa698f0..47cf520c0 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -627,7 +627,7 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list &temp tok = tok->next(); const Token *from = (*it)->next(); std::stack links; - while (from && (!links.empty() || (from->str() != "," && (indentlevel || from->str() != ">")))) { + while (from && (!links.empty() || indentlevel || !Token::Match(from, ",|>"))) { if (from->str() == "<") ++indentlevel; else if (from->str() == ">") diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 183f4cbef..fb1895a0c 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -1144,6 +1144,19 @@ private: "template < class T1 , class T2 = B < T1 > > class C { } ; " "template < class T1 = A , typename T2 = B < A > > class D { } ;", tok(code)); } + { + // #7548 + const char code[] = "template class DefaultMemory {}; " + "template > class thv_table_c {}; " + "thv_table_c id_table_m;"; + const char exp [] = "template < class T , class U > class DefaultMemory { } ; " + "thv_table_c> id_table_m ; " + "class thv_table_c> { } ;"; + const char curr[] = "template < class T , class U > class DefaultMemory { } ; " + "thv_table_c> id_table_m ; " + "class thv_table_c> { } ;"; + TODO_ASSERT_EQUALS(exp, curr, tok(code)); + } } void template_default_type() {