diff options
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
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<TranslationUnitDecl>(SpecializedContext)) S.Diag(Loc, diag::err_template_spec_decl_out_of_scope_global) << EntityKind << Specialized; |