diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-05 07:33:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-05 07:33:43 +0000 |
commit | 525f96c0ef39f91abd26b1b4584ba1814e7ebc28 (patch) | |
tree | cc0f56e69af84be05ac59db1ca7e459d05133baa /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 9da559868fcdd26ac0448a2943cc27af74923eb3 (diff) |
Default function arguments for function template specializations
always come from the primary template, so gather the instantiation
template arguments from the primary template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95380 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index b560fad25e..5c5701ac79 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -33,9 +33,15 @@ using namespace clang; /// arguments. /// /// \param Innermost if non-NULL, the innermost template argument list. +/// +/// \param RelativeToPrimary true if we should get the template +/// arguments relative to the primary template, even when we're +/// dealing with a specialization. This is only relevant for function +/// template specializations. MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs(NamedDecl *D, - const TemplateArgumentList *Innermost) { + const TemplateArgumentList *Innermost, + bool RelativeToPrimary) { // Accumulate the set of template argument lists in this structure. MultiLevelTemplateArgumentList Result; @@ -64,8 +70,9 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, } // Add template arguments from a function template specialization. else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) { - if (Function->getTemplateSpecializationKind() - == TSK_ExplicitSpecialization) + if (!RelativeToPrimary && + Function->getTemplateSpecializationKind() + == TSK_ExplicitSpecialization) break; if (const TemplateArgumentList *TemplateArgs @@ -86,11 +93,13 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, if (Function->getFriendObjectKind() && Function->getDeclContext()->isFileContext()) { Ctx = Function->getLexicalDeclContext(); + RelativeToPrimary = false; continue; } } Ctx = Ctx->getParent(); + RelativeToPrimary = false; } return Result; |