diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-04 22:48:11 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-04 22:48:11 +0000 |
commit | d0e3daf2b980b505e535d35b432c938c6d0208ef (patch) | |
tree | e503ee747ebf8da57ddddaee8b43fa885c75b7b8 /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 4fe95f99a2693f1145785ea5835ba6937e49c730 (diff) |
Improve the AST representation and semantic analysis for extern
templates. We now distinguish between an explicit instantiation
declaration and an explicit instantiation definition, and know not to
instantiate explicit instantiation declarations. Unfortunately, there
is some remaining confusion w.r.t. instantiation of out-of-line member
function definitions that causes trouble here.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81053 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 807115eb67..b63fc400a5 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -402,6 +402,8 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { Decl * TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { + // FIXME: Dig out the out-of-line definition of this function template? + TemplateParameterList *TempParams = D->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) @@ -496,7 +498,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) { D->getStorageClass(), D->isInline(), D->hasWrittenPrototype()); Function->setLexicalDeclContext(Owner); - + // Attach the parameters for (unsigned P = 0; P < Params.size(); ++P) Params[P]->setOwningFunction(Function); @@ -622,7 +624,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, Method->getDeclName(), TemplateParams, Method); if (D->isOutOfLine()) - FunctionTemplate->setLexicalDeclContext(D->getLexicalDeclContext()); + FunctionTemplate->setLexicalDeclContext(D->getLexicalDeclContext()); Method->setDescribedFunctionTemplate(FunctionTemplate); } else if (!FunctionTemplate) Method->setInstantiationOfMemberFunction(D); @@ -979,6 +981,15 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (!Pattern) return; + // C++0x [temp.explicit]p9: + // Except for inline functions, other explicit instantiation declarations + // have the effect of suppressing the implicit instantiation of the entity + // to which they refer. + if (Function->getTemplateSpecializationKind() + == TSK_ExplicitInstantiationDeclaration && + PatternDecl->isOutOfLine() && !PatternDecl->isInline()) + return; + InstantiatingTemplate Inst(*this, PointOfInstantiation, Function); if (Inst) return; @@ -1080,6 +1091,8 @@ void Sema::InstantiateStaticDataMemberDefinition( return; } + // FIXME: extern templates + InstantiatingTemplate Inst(*this, PointOfInstantiation, Var); if (Inst) return; |