Fixed #9076 (Template Simplifier : template < template <typename> T >) (#1777)

This does not add support for template templates.  It only skips the
template template parameter.
This commit is contained in:
IOBYTE 2019-04-03 00:02:38 -04:00 committed by Daniel Marjamäki
parent 3f9dd4c567
commit 9f3ecdde31
2 changed files with 17 additions and 0 deletions

View File

@ -626,6 +626,9 @@ bool TemplateSimplifier::getTemplateDeclarations()
}
if (!Token::simpleMatch(tok, "template <"))
continue;
// ignore template template parameter
if (tok->strAt(-1) == "<")
continue;
// Some syntax checks, see #6865
if (!tok->tokAt(2))
syntaxError(tok->next());

View File

@ -142,6 +142,7 @@ private:
TEST_CASE(template102); // #9005
TEST_CASE(template103);
TEST_CASE(template104); // #9021
TEST_CASE(template105); // #9076
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
@ -2384,6 +2385,19 @@ private:
ASSERT_EQUALS(exp, tok(code));
}
void template105() { // #9076
const char code[] = "template <template <typename> class TOUT> class ObjectCache;\n"
"template <template <typename> class TOUT>\n"
"class ObjectCache { };\n"
"template <typename T> class Fred {};\n"
"ObjectCache<Fred> _cache;";
const char exp[] = "class ObjectCache<Fred> ; "
"template < typename T > class Fred { } ; "
"ObjectCache<Fred> _cache ; "
"class ObjectCache<Fred> { } ;";
ASSERT_EQUALS(exp, tok(code));
}
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
const char code[] = "template <typename T> struct C {};\n"
"template <typename T> struct S {a};\n"