diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-09-12 05:08:28 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-09-12 05:08:28 +0000 |
| commit | b1aab4388791192029e59462819eebb820ee3631 (patch) | |
| tree | 0e0b36c45e39307b3d4e809e14b881ab7541965f /clang | |
| parent | 488b4a7d943bcbdf490d40868902fcd556dd4299 (diff) | |
| download | bcm5719-llvm-b1aab4388791192029e59462819eebb820ee3631.tar.gz bcm5719-llvm-b1aab4388791192029e59462819eebb820ee3631.zip | |
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.
llvm-svn: 113717
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 0fc83927b79..851f7b96045 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/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; |

