From: Daniel Dunbar Date: Wed, 9 Mar 2011 23:24:34 +0000 (+0000) Subject: Revert r127206 "Detect attempts to provide a specialization of a function within X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=975cc644d5d9dafdb4060aa31c9753d0554e1308;p=clang Revert r127206 "Detect attempts to provide a specialization of a function within a...", it appears to cause us to reject various valid codes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127373 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e862960379..982ed25103 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1723,8 +1723,6 @@ def err_template_spec_default_arg : Error< def err_not_class_template_specialization : Error< "cannot specialize a %select{dependent template|template template " "parameter}0">; -def err_function_specialization_in_class : Error< - "cannot specialize a function %0 within class scope">; // C++ class template specializations and out-of-line definitions def err_template_spec_needs_header : Error< diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index dab4bf7fbe..5e3c5fe8ef 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4083,14 +4083,9 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, Previous)) NewFD->setInvalidDecl(); } else if (isFunctionTemplateSpecialization) { - 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)) + if (CheckFunctionTemplateSpecialization(NewFD, + (HasExplicitTemplateArgs ? &TemplateArgs : 0), + Previous)) NewFD->setInvalidDecl(); } else if (isExplicitSpecialization && isa(NewFD)) { if (CheckMemberSpecialization(NewFD, Previous)) diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp index 2295235570..1032a87def 100644 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp +++ b/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp @@ -237,15 +237,3 @@ void test_func_template(N0::X0 xvp, void *vp, const void *cvp, xvp.ft1(vp, i); xvp.ft1(vp, u); } - -namespace PR8979 { - template - struct X0 { - template class Inner; - struct OtherInner; - template void f(Inner&); - - typedef Inner MyInner; - template<> void f(MyInner&); // expected-error{{cannot specialize a function 'f' within class scope}} - }; -}