pt.c (register_specialization): Correct argument to check_specialization_namespace.
authorJason Merrill <jason@redhat.com>
Fri, 24 Aug 2012 18:57:50 +0000 (14:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 24 Aug 2012 18:57:50 +0000 (14:57 -0400)
* pt.c (register_specialization): Correct argument to
check_specialization_namespace.
(determine_specialization): Don't consider members of
unspecialized types.

From-SVN: r190652

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/spec25.C

index 0c8911180aa4a30ef124f204d54c3ac194538dc9..9eb4b87420cbae5a1dfbbb7ce5debe72616a3f26 100644 (file)
@@ -1,3 +1,10 @@
+2012-08-24  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (register_specialization): Correct argument to
+       check_specialization_namespace.
+       (determine_specialization): Don't consider members of
+       unspecialized types.
+
 2012-08-23  Jason Merrill  <jason@redhat.com>
 
        * decl.c (compute_array_index_type): Use type_dependent_expression_p.
index ad81bab3c83f45a2508939661fafa258eebbc113..580a3d4b099729c97d7702c370a14efbb9e0a350 100644 (file)
@@ -735,7 +735,7 @@ end_explicit_instantiation (void)
   processing_explicit_instantiation = false;
 }
 
-/* An explicit specialization or partial specialization TMPL is being
+/* An explicit specialization or partial specialization of TMPL is being
    declared.  Check that the namespace in which the specialization is
    occurring is permissible.  Returns false iff it is invalid to
    specialize TMPL in the current namespace.  */
@@ -1407,7 +1407,7 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend,
                  DECL_SOURCE_LOCATION (clone)
                    = DECL_SOURCE_LOCATION (fn);
                }
-             check_specialization_namespace (fn);
+             check_specialization_namespace (tmpl);
 
              return fn;
            }
@@ -1804,6 +1804,16 @@ determine_specialization (tree template_id,
   if (template_id == error_mark_node || decl == error_mark_node)
     return error_mark_node;
 
+  /* We shouldn't be specializing a member template of an
+     unspecialized class template; we already gave an error in
+     check_specialization_scope, now avoid crashing.  */
+  if (template_count && DECL_CLASS_SCOPE_P (decl)
+      && template_class_depth (DECL_CONTEXT (decl)) > 0)
+    {
+      gcc_assert (errorcount);
+      return error_mark_node;
+    }
+
   fns = TREE_OPERAND (template_id, 0);
   explicit_targs = TREE_OPERAND (template_id, 1);
 
index 3f641fe5a212b3cee86eb0af810e60350db439e5..385d19ada0c45048e91e2d9be2610969abb457e6 100644 (file)
@@ -1,10 +1,10 @@
 namespace N {
   template <typename T>
   struct S {
-    void f() {}
+    void f() {}                        // { dg-error "definition" }
   };
 }
 
 namespace K {
-  template <> void N::S<char>::f() {} // { dg-error "namespace|definition" }
+  template <> void N::S<char>::f() {} // { dg-error "different namespace" }
 }