Merge pull request #856 from simartin/ticket_7548

Ticket #7548: Properly detect the end of template parameter default values during instantiation
This commit is contained in:
Daniel Marjamäki 2017-01-08 16:39:33 +01:00 committed by GitHub
commit 24996300a5
2 changed files with 14 additions and 1 deletions

View File

@ -627,7 +627,7 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &temp
tok = tok->next();
const Token *from = (*it)->next();
std::stack<Token *> 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() == ">")

View File

@ -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 T, class U> class DefaultMemory {}; "
"template<class Key, class Val, class Mem=DefaultMemory<Key,Val> > class thv_table_c {}; "
"thv_table_c<void *,void *> id_table_m;";
const char exp [] = "template < class T , class U > class DefaultMemory { } ; "
"thv_table_c<void*,void*,DefaultMemory<void*,void*>> id_table_m ; "
"class thv_table_c<void*,void*,DefaultMemory<void*,void*>> { } ;";
const char curr[] = "template < class T , class U > class DefaultMemory { } ; "
"thv_table_c<void*,void*,DefaultMemory<Key,Val>> id_table_m ; "
"class thv_table_c<void*,void*,DefaultMemory<Key,Val>> { } ;";
TODO_ASSERT_EQUALS(exp, curr, tok(code));
}
}
void template_default_type() {