summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-04-17 22:30:01 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-04-17 22:30:01 +0000
commit79a52e5709895269f51734dd28aa51e5e279dd27 (patch)
tree2cf9c5b52417a6e87c8d7d71480fea121ba86834 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent828531f798ab49a546e56245ff876eec27e42a43 (diff)
downloadbcm5719-llvm-79a52e5709895269f51734dd28aa51e5e279dd27.tar.gz
bcm5719-llvm-79a52e5709895269f51734dd28aa51e5e279dd27.zip
PR12569: Instantiate exception specifications of explicit instantiations
and explicit specializations of function templates appropriately. llvm-svn: 154956
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 39c27fc497c..4d312f855f5 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/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()
OpenPOWER on IntegriCloud