diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 88c3a770c272..9db681446662 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3972,7 +3972,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, ? TPC_FriendFunctionTemplateDefinition : TPC_FriendFunctionTemplate) : (D.getCXXScopeSpec().isSet() && - DC && DC->isRecord()) + DC && DC->isRecord() && + DC->isDependentContext()) ? TPC_ClassTemplateMember : TPC_FunctionTemplate); } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index e867354273fc..88ba3f9a8857 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -947,7 +947,8 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, if (CheckTemplateParameterList(TemplateParams, PrevClassTemplate? PrevClassTemplate->getTemplateParameters() : 0, (SS.isSet() && SemanticContext && - SemanticContext->isRecord()) + SemanticContext->isRecord() && + SemanticContext->isDependentContext()) ? TPC_ClassTemplateMember : TPC_ClassTemplate)) Invalid = true; diff --git a/clang/test/CXX/temp/temp.param/p9-0x.cpp b/clang/test/CXX/temp/temp.param/p9-0x.cpp index c9d5bfb01736..17eca7f7e85d 100644 --- a/clang/test/CXX/temp/temp.param/p9-0x.cpp +++ b/clang/test/CXX/temp/temp.param/p9-0x.cpp @@ -22,10 +22,10 @@ struct X3 { } }; -namespace PR8747 { +namespace PR8748 { // Testcase 1 struct A0 { template struct B; }; - template struct A0::B { }; // expected-error{{cannot add a default template argument to the definition of a member of a class template}} + template struct A0::B { }; // Testcase 2 template struct A1 { template struct B; };