]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/28300 (In-class partial specialization of class accepted)
authorJason Merrill <jason@redhat.com>
Fri, 18 Dec 2009 20:49:58 +0000 (15:49 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 18 Dec 2009 20:49:58 +0000 (15:49 -0500)
PR c++/28300
PR c++/42062
* pt.c (check_specialization_namespace): Complain about
specialization at non-namespace scope.

From-SVN: r155349

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/spec37.C [new file with mode: 0644]

index 4109c72cd71eaa05ef04931a68d4e2d6ec3bf54b..3bbc3fddae0cb0e61e762f5330800a466402ae54 100644 (file)
@@ -1,5 +1,10 @@
 2009-12-18  Jason Merrill  <jason@redhat.com>
 
+       PR c++/28300
+       PR c++/42062
+       * pt.c (check_specialization_namespace): Complain about
+       specialization at non-namespace scope.
+
        PR c++/42415
        * call.c (build_new_method_call): Complain about calling the
        constructor directly.
index 395a026311c585ac536bd5eb6ddc64a68194d54b..5d98cbdb496b8caebf4a200250fed3d47927ff8c 100644 (file)
@@ -742,6 +742,12 @@ check_specialization_namespace (tree tmpl)
      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.  */
+  if (current_scope() != DECL_CONTEXT (tmpl)
+      && !at_namespace_scope_p ())
+    {
+      error ("specialization of %qD must appear at namespace scope", tmpl);
+      return false;
+    }
   if (is_associated_namespace (current_namespace, tpl_ns))
     /* Same or super-using namespace.  */
     return true;
index af4e2ac87538b0d6da44dd4391edfaea0dfe9d49..3167b8b32adaed4110f9ac10d1e0a303a3802e1d 100644 (file)
@@ -1,5 +1,8 @@
 2009-12-18  Jason Merrill  <jason@redhat.com>
 
+       PR c++/28300
+       * g++.dg/template/spec37.C: New.
+
        PR c++/42415
        * g++.dg/tc1/dr147.C: Add test.
 
diff --git a/gcc/testsuite/g++.dg/template/spec37.C b/gcc/testsuite/g++.dg/template/spec37.C
new file mode 100644 (file)
index 0000000..2c01eb0
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/28300
+
+template<typename> struct A
+{
+    template<typename T> struct A<T*>; // { dg-error "namespace scope" }
+};