aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-12 05:08:28 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-12 05:08:28 +0000
commit121dc9ab38bda202720c506c26c67457eb967f02 (patch)
treed8d241333d7c8b1e74e1f099ff04cfe9b7e01ec0
parent8dc3abcc36df883324461daad0c05364158f3cf0 (diff)
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
-rw-r--r--lib/Sema/SemaTemplate.cpp17
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;