summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-03-16 19:27:09 +0000
committerDouglas Gregor <dgregor@apple.com>2011-03-16 19:27:09 +0000
commit63fab344695e4eb9f6ffed808b78e7d8b8f7744d (patch)
tree8ab9872ff2beb3d4d87f179edb3d4a216cce1720 /clang/lib/Sema/SemaDecl.cpp
parentd6278e3252f6fc04a954bf42d8fdd02a960657aa (diff)
downloadbcm5719-llvm-63fab344695e4eb9f6ffed808b78e7d8b8f7744d.tar.gz
bcm5719-llvm-63fab344695e4eb9f6ffed808b78e7d8b8f7744d.zip
Detect attempts to provide a specialization of a function within a
dependent scope and produce an error (rather than crashing). Fixes PR8979. llvm-svn: 127749
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 65a372850f2..a10b32513d3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4102,9 +4102,15 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
Previous))
NewFD->setInvalidDecl();
} else if (isFunctionTemplateSpecialization) {
- if (CheckFunctionTemplateSpecialization(NewFD,
- (HasExplicitTemplateArgs ? &TemplateArgs : 0),
- Previous))
+ if (CurContext->isDependentContext() && CurContext->isRecord()
+ && !isFriend) {
+ Diag(NewFD->getLocation(), diag::err_function_specialization_in_class)
+ << NewFD->getDeclName();
+ NewFD->setInvalidDecl();
+ return 0;
+ } else if (CheckFunctionTemplateSpecialization(NewFD,
+ (HasExplicitTemplateArgs ? &TemplateArgs : 0),
+ Previous))
NewFD->setInvalidDecl();
} else if (isExplicitSpecialization && isa<CXXMethodDecl>(NewFD)) {
if (CheckMemberSpecialization(NewFD, Previous))
OpenPOWER on IntegriCloud