diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-08 02:04:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-08 02:04:14 +0000 |
commit | 6203d49b0ecc35516983502bd706259b2c3b14ed (patch) | |
tree | 7a670b23f8b984afbf91ef39bc6fb232791a4918 /clang/lib/Sema/SemaDecl.cpp | |
parent | bd3f26069840d2743e150004ab98cc3f0c969f08 (diff) | |
download | bcm5719-llvm-6203d49b0ecc35516983502bd706259b2c3b14ed.tar.gz bcm5719-llvm-6203d49b0ecc35516983502bd706259b2c3b14ed.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: 127206
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b6191e82cd2..f957fb7c164 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4067,9 +4067,14 @@ 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()) { + 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)) |