diff options
author | ed <ed@FreeBSD.org> | 2009-06-23 14:50:21 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-23 14:50:21 +0000 |
commit | da468bf93e74598f985f4988936ee5ca2dc9a38c (patch) | |
tree | 64b43af65e97f7659637c9ac028e39af2e26b841 /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 8927c19a5ed03bef55dac4b623688387bcc794dc (diff) | |
download | FreeBSD-src-da468bf93e74598f985f4988936ee5ca2dc9a38c.zip FreeBSD-src-da468bf93e74598f985f4988936ee5ca2dc9a38c.tar.gz |
Import Clang r73954.
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6d7dc2e..ece71bc 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -163,6 +163,9 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { if (Invalid) BitWidth = 0; else if (BitWidth) { + // The bit-width expression is not potentially evaluated. + EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); + OwningExprResult InstantiatedBitWidth = SemaRef.InstantiateExpr(BitWidth, TemplateArgs); if (InstantiatedBitWidth.isInvalid()) { @@ -192,6 +195,9 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) { Expr *AssertExpr = D->getAssertExpr(); + // The expression in a static assertion is not potentially evaluated. + EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); + OwningExprResult InstantiatedAssertExpr = SemaRef.InstantiateExpr(AssertExpr, TemplateArgs); if (InstantiatedAssertExpr.isInvalid()) @@ -222,8 +228,13 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { EC != ECEnd; ++EC) { // The specified value for the enumerator. OwningExprResult Value = SemaRef.Owned((Expr *)0); - if (Expr *UninstValue = EC->getInitExpr()) + if (Expr *UninstValue = EC->getInitExpr()) { + // The enumerator's value expression is not potentially evaluated. + EnterExpressionEvaluationContext Unevaluated(SemaRef, + Action::Unevaluated); + Value = SemaRef.InstantiateExpr(UninstValue, TemplateArgs); + } // Drop the initial value and continue. bool isInvalid = false; @@ -586,6 +597,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (Function->isInvalidDecl()) return; + assert(!Function->getBody(Context) && "Already instantiated!"); + // Find the function body that we'll be substituting. const FunctionDecl *PatternDecl = Function->getInstantiatedFromMemberFunction(); @@ -765,3 +778,18 @@ NamedDecl * Sema::InstantiateCurrentDeclRef(NamedDecl *D) { return D; } + +/// \brief Performs template instantiation for all implicit template +/// instantiations we have seen until this point. +void Sema::PerformPendingImplicitInstantiations() { + while (!PendingImplicitInstantiations.empty()) { + PendingImplicitInstantiation Inst = PendingImplicitInstantiations.front(); + PendingImplicitInstantiations.pop(); + + if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Inst.first)) + if (!Function->getBody(Context)) + InstantiateFunctionDefinition(/*FIXME:*/Inst.second, Function); + + // FIXME: instantiation static member variables + } +} |