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/Sema/SemaTemplateInstantiateDecl.cpp | |
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/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
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() |