Fix 10506: Hang: template alias (TemplateSimplfier) (#3466)
This commit is contained in:
parent
5c3b69fe96
commit
d1181ad8e2
|
@ -2244,10 +2244,9 @@ void TemplateSimplifier::expandTemplate(
|
|||
|
||||
// add new instantiations
|
||||
for (const auto & inst : newInstantiations) {
|
||||
std::string fullName = inst.scope + (inst.scope.empty() ? "" : " :: ") + inst.token->str();
|
||||
simplifyTemplateArgs(inst.token->tokAt(2), inst.token->next()->findClosingBracket());
|
||||
// only add recursive instantiation if its arguments are a constant expression
|
||||
if (templateDeclaration.fullName() != fullName ||
|
||||
if (templateDeclaration.name() != inst.token->str() ||
|
||||
(inst.token->tokAt(2)->isNumber() || inst.token->tokAt(2)->isStandardType()))
|
||||
mTemplateInstantiations.emplace_back(inst.token, inst.scope);
|
||||
}
|
||||
|
|
|
@ -214,6 +214,7 @@ private:
|
|||
TEST_CASE(template171); // crash
|
||||
TEST_CASE(template172); // #10258 crash
|
||||
TEST_CASE(template173); // #10332 crash
|
||||
TEST_CASE(template174); // #10506 hang
|
||||
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)
|
||||
|
@ -4439,6 +4440,19 @@ private:
|
|||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
|
||||
void template174()
|
||||
{ // #10506 hang
|
||||
const char code[] = "namespace a {\n"
|
||||
"template <typename> using b = int;\n"
|
||||
"template <typename c> c d() { return d<b<c>>(); }\n"
|
||||
"}\n"
|
||||
"void e() { a::d<int>(); }\n";
|
||||
const char exp[] = "namespace a { int d<int> ( ) ; } "
|
||||
"void e ( ) { a :: d<int> ( ) ; } "
|
||||
"int a :: d<int> ( ) { return d < int > ( ) ; }";
|
||||
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"
|
||||
|
|
Loading…
Reference in New Issue