diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-04-17 22:30:01 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-04-17 22:30:01 +0000 |
commit | 87162c2e528921aabb84e96fe7272348a4b3354e (patch) | |
tree | 7971c636196449ca3e43c3fd017c43996a43fd4c /lib | |
parent | 9591697707c69af99bb196d70895f4e7e28be333 (diff) |
PR12569: Instantiate exception specifications of explicit instantiations
and explicit specializations of function templates appropriately.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 11 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c7bd72b03e..1550993079 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -7185,8 +7185,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, } } -Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, - Declarator &D) { +Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) { assert(getCurFunctionDecl() == 0 && "Function parsing confused"); assert(D.isFunctionDeclarator() && "Not a function declarator!"); Scope *ParentScope = FnBodyScope->getParent(); @@ -7359,6 +7358,10 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { } } + // Ensure that the function's exception specification is instantiated. + if (const FunctionProtoType *FPT = FD->getType()->getAs<FunctionProtoType>()) + ResolveExceptionSpec(D->getLocation(), FPT); + // Checking attributes of current function definition // dllimport attribute. DLLImportAttr *DA = FD->getAttr<DLLImportAttr>(); diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 39c27fc497..4d312f855f 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2377,7 +2377,16 @@ static void InstantiateExceptionSpec(Sema &SemaRef, FunctionDecl *New, void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Decl) { - FunctionDecl *Tmpl = Decl->getTemplateInstantiationPattern(); + // Find the template declaration which contains the exception specification. + // Per [except.spec]p4, prefer the exception spec on the primary template + // if this is an explicit instantiation. + FunctionDecl *Tmpl = 0; + if (Decl->getPrimaryTemplate()) + Tmpl = Decl->getPrimaryTemplate()->getTemplatedDecl(); + else if (FunctionDecl *MemTmpl = Decl->getInstantiatedFromMemberFunction()) + Tmpl = MemTmpl; + else + Tmpl = Decl->getTemplateInstantiationPattern(); assert(Tmpl && "can't instantiate non-template"); if (Decl->getType()->castAs<FunctionProtoType>()->getExceptionSpecType() |