diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-30 23:23:59 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-30 23:23:59 +0000 |
commit | 71b87e4fa6bfb47107b099135864f9024004a4c9 (patch) | |
tree | 7ff9efa3eefe9e8d60ad6fa76d4c36bdad479b45 | |
parent | 2d804c4325fcf3893386e16970b82fd0f9af1d7c (diff) |
When template substitution into a template parameter reduces the level
of that parameter, reduce the level by the number of active template
argument lists rather than by 1. The number of active template
argument lists is only > 1 when we have a class template partial
specialization of a member template of a class template that itself is
a member template of another class template.
... and Boost.MSM does this. Fixes PR7669.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112551 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 14 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-member-template.cpp | 14 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 26fbe6a114..2566d04308 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1461,8 +1461,8 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl( TemplateTypeParmDecl *Inst = TemplateTypeParmDecl::Create(SemaRef.Context, Owner, D->getLocation(), - TTPT->getDepth() - 1, TTPT->getIndex(), - TTPT->getName(), + TTPT->getDepth() - TemplateArgs.getNumLevels(), + TTPT->getIndex(),TTPT->getName(), D->wasDeclaredWithTypename(), D->isParameterPack()); @@ -1503,8 +1503,9 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( NonTypeTemplateParmDecl *Param = NonTypeTemplateParmDecl::Create(SemaRef.Context, Owner, D->getLocation(), - D->getDepth() - 1, D->getPosition(), - D->getIdentifier(), T, DI); + D->getDepth() - TemplateArgs.getNumLevels(), + D->getPosition(), D->getIdentifier(), T, + DI); if (Invalid) Param->setInvalidDecl(); @@ -1534,8 +1535,9 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( // Build the template template parameter. TemplateTemplateParmDecl *Param = TemplateTemplateParmDecl::Create(SemaRef.Context, Owner, D->getLocation(), - D->getDepth() - 1, D->getPosition(), - D->getIdentifier(), InstParams); + D->getDepth() - TemplateArgs.getNumLevels(), + D->getPosition(), D->getIdentifier(), + InstParams); Param->setDefaultArgument(D->getDefaultArgument(), false); // Introduce this template parameter's instantiation into the instantiation diff --git a/test/SemaTemplate/instantiate-member-template.cpp b/test/SemaTemplate/instantiate-member-template.cpp index 24a3f317e6..8f4063bc71 100644 --- a/test/SemaTemplate/instantiate-member-template.cpp +++ b/test/SemaTemplate/instantiate-member-template.cpp @@ -189,3 +189,17 @@ namespace PR7587 { }; } + +namespace PR7669 { + template<class> struct X { + template<class> struct Y { + template<int,class> struct Z; + template<int Dummy> struct Z<Dummy,int> {}; + }; + }; + + void a() + { + X<int>::Y<int>::Z<0,int>(); + } +} |