OSDN Git Service

PR c++/28300
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Dec 2009 20:49:58 +0000 (20:49 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Dec 2009 20:49:58 +0000 (20:49 +0000)
PR c++/42062
* pt.c (check_specialization_namespace): Complain about
specialization at non-namespace scope.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155349 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 4109c72..3bbc3fd 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 395a026..5d98cbd 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 af4e2ac..3167b8b 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" }
+};