From: Douglas Gregor Date: Sun, 12 Sep 2010 05:08:28 +0000 (+0000) Subject: Implement C++0x semantics for [temp.expl.spec]p2, which loosens the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=121dc9ab38bda202720c506c26c67457eb967f02;p=clang Implement C++0x semantics for [temp.expl.spec]p2, which loosens the restrictions on out-of-line specializations to allow them anywhere in an enclosing context. Motivated by PR8084. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113717 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 0fc83927b7..851f7b9604 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -3441,10 +3441,19 @@ static bool CheckTemplateSpecializationScope(Sema &S, if ((!PrevDecl || getTemplateSpecializationKind(PrevDecl) == TSK_Undeclared || getTemplateSpecializationKind(PrevDecl) == TSK_ImplicitInstantiation)){ - // There is no prior declaration of this entity, so this - // specialization must be in the same context as the template - // itself, or in the enclosing namespace set. - if (!DC->InEnclosingNamespaceSetOf(SpecializedContext)) { + // C++ [temp.exp.spec]p2: + // An explicit specialization shall be declared in the namespace of which + // the template is a member, or, for member templates, in the namespace + // of which the enclosing class or enclosing class template is a member. + // An explicit specialization of a member function, member class or + // static data member of a class template shall be declared in the + // namespace of which the class template is a member. + // + // C++0x [temp.expl.spec]p2: + // An explicit specialization shall be declared in a namespace enclosing + // the specialized template. + if (!DC->InEnclosingNamespaceSetOf(SpecializedContext) && + !(S.getLangOptions().CPlusPlus0x && DC->Encloses(SpecializedContext))) { if (isa(SpecializedContext)) S.Diag(Loc, diag::err_template_spec_decl_out_of_scope_global) << EntityKind << Specialized;