[cfe-commits] r113717 - /cfe/trunk/lib/Sema/SemaTemplate.cpp

Douglas Gregor dgregor at apple.com
Sat Sep 11 22:08:28 PDT 2010


Author: dgregor
Date: Sun Sep 12 00:08:28 2010
New Revision: 113717

URL: http://llvm.org/viewvc/llvm-project?rev=113717&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=113717&r1=113716&r2=113717&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sun Sep 12 00:08:28 2010
@@ -3441,10 +3441,19 @@
   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;





More information about the cfe-commits mailing list