diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index dca99e050..19a58e0d8 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -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); } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index e11d3a3b6..6597edf1d 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -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 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) @@ -4439,6 +4440,19 @@ private: ASSERT_EQUALS(exp, tok(code)); } + void template174() + { // #10506 hang + const char code[] = "namespace a {\n" + "template using b = int;\n" + "template c d() { return d>(); }\n" + "}\n" + "void e() { a::d(); }\n"; + const char exp[] = "namespace a { int d ( ) ; } " + "void e ( ) { a :: d ( ) ; } " + "int a :: d ( ) { return d < int > ( ) ; }"; + 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"