From 9f6f6a107287bd81aedab8b578216535b0b51d0f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 10 Dec 2010 17:08:53 +0000 Subject: Do not substitute template types if template has dependent context We should not substitute template types if the template has a dependent context because the template argument stack is not yet fully formed. Instead, defer substitution until the template has a non-dependent context (i.e. instantiation of an outer template). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121491 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplate.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/Sema/SemaTemplate.cpp') diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 7539a56965..53a02a9886 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2110,9 +2110,12 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, // Check non-type template parameters. if (NonTypeTemplateParmDecl *NTTP =dyn_cast(Param)) { // Do substitution on the type of the non-type template parameter - // with the template arguments we've seen thus far. + // with the template arguments we've seen thus far. But if the + // template has a dependent context then we cannot substitute yet. QualType NTTPType = NTTP->getType(); - if (NTTPType->isDependentType()) { + if (NTTPType->isDependentType() && + !isa(Template) && + !Template->getDeclContext()->isDependentContext()) { // Do substitution on the type of the non-type template parameter. InstantiatingTemplate Inst(*this, TemplateLoc, Template, NTTP, Converted.data(), Converted.size(), -- cgit v1.2.3-18-g5258