diff options
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() |