pt.c (maybe_process_partial_specialization): Complain about specialization in wrong...
authorJason Merrill <jason@gcc.gnu.org>
Sun, 7 Feb 1999 15:44:12 +0000 (10:44 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 7 Feb 1999 15:44:12 +0000 (10:44 -0500)
* pt.c (maybe_process_partial_specialization): Complain about
specialization in wrong namespace.
* tree.c (decl_namespace_context): New fn.
g++.pt/explicit73.C
* decl2.c (arg_assoc_type): Handle TEMPLATE_TEMPLATE_PARM.
* pt.c (coerce_template_template_parms): Handle nested
template template parameters.
g++.pt/nttp[12].C

From-SVN: r25072

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/cp/tree.c

index 2248d9c9f39f848e97a4c6082493b723c4bdfc70..975769f4105a000e02eafc8e58d672a85c08e25b 100644 (file)
@@ -1,3 +1,15 @@
+1999-02-07  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * pt.c (maybe_process_partial_specialization): Complain about
+       specialization in wrong namespace.
+       * tree.c (decl_namespace_context): New fn.
+
+1999-02-06  Kriang Lerdsuwanakij <lerdsuwa@scf-fs.usc.edu>
+
+       * decl2.c (arg_assoc_type): Handle TEMPLATE_TEMPLATE_PARM.
+       * pt.c (coerce_template_template_parms): Handle nested 
+       template template parameters.
+
 Sat Feb  6 18:08:40 1999  Jeffrey A Law  (law@cygnus.com)
 
        * typeck2.c: Update email addrsses.
index 1d7385c4223434b8f3b3e67373e87cbb0287e5fa..6bed0bcded3c2b6bcc2823934ab9259ce01e6b14 100644 (file)
@@ -3288,6 +3288,7 @@ extern tree break_out_target_exprs                PROTO((tree));
 extern tree get_type_decl                      PROTO((tree));
 extern tree vec_binfo_member                   PROTO((tree, tree));
 extern tree hack_decl_function_context                 PROTO((tree));
+extern tree decl_namespace_context             PROTO((tree));
 extern tree lvalue_type                                PROTO((tree));
 extern tree error_type                         PROTO((tree));
 extern tree make_temp_vec                      PROTO((int));
index ba458595f6bd47fc8d6eb30bccdca23e74c6aa60..87a257787489b0ed7a9191508cab5ad67d4eb098 100644 (file)
@@ -4483,6 +4483,7 @@ arg_assoc_type (k, type)
       /* Associate the return type. */
       return arg_assoc_type (k, TREE_TYPE (type));
     case TEMPLATE_TYPE_PARM:
+    case TEMPLATE_TEMPLATE_PARM:
       return 0;
     case LANG_TYPE:
       if (type == unknown_type_node)
index dd805da3967868cb4b8a0bc1c910ced48b91f801..72cf9d0b60fe8b5fb6c03fd8176f4ef0dcc70806 100644 (file)
@@ -672,6 +672,13 @@ maybe_process_partial_specialization (type)
       if (CLASSTYPE_IMPLICIT_INSTANTIATION (type)
          && TYPE_SIZE (type) == NULL_TREE)
        {
+         if (current_namespace
+             != decl_namespace_context (CLASSTYPE_TI_TEMPLATE (type)))
+           {
+             cp_pedwarn ("specializing `%#T' in different namespace", type);
+             cp_pedwarn_at ("  from definition of `%#D'",
+                            CLASSTYPE_TI_TEMPLATE (type));
+           }
          SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (type);
          if (processing_template_decl)
            push_template_decl (TYPE_MAIN_DECL (type));
@@ -2804,8 +2811,15 @@ coerce_template_template_parms (parm_parms, arg_parms, in_decl, outer_args)
          /* We encounter instantiations of templates like
               template <template <template <class> class> class TT>
               class C;  */
-         sorry ("nested template template parameter");
-         return 0;
+         {
+           tree parmparm = DECL_INNERMOST_TEMPLATE_PARMS (parm);
+           tree argparm = DECL_INNERMOST_TEMPLATE_PARMS (arg);
+
+           if (!coerce_template_template_parms (parmparm, argparm, 
+                                                in_decl, outer_args))
+             return 0;
+         }
+         break;
 
        case PARM_DECL:
          /* The tsubst call is used to handle cases such as
index 3e5048f9f10b33ed74911f2305f4c30076b2ebf7..bc5a18eba7d40bf4f73fca794037040b57c30e0a 100644 (file)
@@ -2384,6 +2384,24 @@ hack_decl_function_context (decl)
   return decl_function_context (decl);
 }
 
+/* Returns the namespace that contains DECL, whether directly or
+   indirectly.  */
+
+tree
+decl_namespace_context (decl)
+     tree decl;
+{
+  while (1)
+    {
+      if (TREE_CODE (decl) == NAMESPACE_DECL)
+       return decl;
+      else if (TYPE_P (decl))
+       decl = CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl));
+      else
+       decl = CP_DECL_CONTEXT (decl);
+    }
+}
+
 /* Return truthvalue of whether T1 is the same tree structure as T2.
    Return 1 if they are the same.
    Return 0 if they are understandably different.