Index: cfe/trunk/lib/Sema/SemaDecl.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp +++ cfe/trunk/lib/Sema/SemaDecl.cpp @@ -8962,10 +8962,10 @@ diag::ext_function_specialization_in_class : diag::err_function_specialization_in_class) << NewFD->getDeclName(); - } else if (CheckFunctionTemplateSpecialization(NewFD, - (HasExplicitTemplateArgs ? &TemplateArgs - : nullptr), - Previous)) + } else if (!NewFD->isInvalidDecl() && + CheckFunctionTemplateSpecialization( + NewFD, (HasExplicitTemplateArgs ? &TemplateArgs : nullptr), + Previous)) NewFD->setInvalidDecl(); // C++ [dcl.stc]p1: Index: cfe/trunk/test/SemaTemplate/deduction-crash.cpp =================================================================== --- cfe/trunk/test/SemaTemplate/deduction-crash.cpp +++ cfe/trunk/test/SemaTemplate/deduction-crash.cpp @@ -144,3 +144,20 @@ template int n; // expected-error +{{}} expected-note {{}} int k = n; } + +namespace deduceFunctionSpecializationForInvalidOutOfLineFunction { + +template +struct SourceSelectionRequirement { + template + OutputT evaluateSelectionRequirement(InputT &&Value) { + } +}; + +template +OutputT SourceSelectionRequirement:: +evaluateSelectionRequirement(InputT &&Value) { // expected-error {{cannot specialize a member of an unspecialized template}} + return Value; +} + +} Index: cfe/trunk/test/SemaTemplate/explicit-specialization-member.cpp =================================================================== --- cfe/trunk/test/SemaTemplate/explicit-specialization-member.cpp +++ cfe/trunk/test/SemaTemplate/explicit-specialization-member.cpp @@ -38,24 +38,20 @@ template template - void Baz::bar() { // expected-note {{couldn't infer template argument 'N'}} + void Baz::bar() { } - // FIXME: We shouldn't try to match this against a prior declaration if - // template parameter matching failed. template - void Baz::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}} \ - // expected-error {{no function template matches}} + void Baz::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}} } } namespace PR19340 { template struct Helper { - template static void func(const T *m) {} // expected-note {{failed template argument deduction}} + template static void func(const T *m) {} }; -template void Helper::func<2>() {} // expected-error {{cannot specialize a member}} \ - // expected-error {{no function template matches}} +template void Helper::func<2>() {} // expected-error {{cannot specialize a member}} } namespace SpecLoc {