From c851d6cf4a4ab803d01d0059f4659f4f9f4435ea Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 17 Jun 2020 14:49:03 -0700 Subject: [PATCH] When performing a substitution into a dependent alias template, mark the outer levels as retained rather than omitting their arguments. This better reflects what's going on (we're performing a substitution while still inside a template). In theory this is also more correct, but I've not found a testcase where it matters in practice (largely because we don't allow alias templates to be declared inside a function). --- clang/lib/Sema/SemaTemplate.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 073b4e818a24..3292284d63ba 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3558,9 +3558,8 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // Only substitute for the innermost template argument list. MultiLevelTemplateArgumentList TemplateArgLists; TemplateArgLists.addOuterTemplateArguments(&StackTemplateArgs); - unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth(); - for (unsigned I = 0; I < Depth; ++I) - TemplateArgLists.addOuterTemplateArguments(None); + TemplateArgLists.addOuterRetainedLevels( + AliasTemplate->getTemplateParameters()->getDepth()); LocalInstantiationScope Scope(*this); InstantiatingTemplate Inst(*this, TemplateLoc, Template);