pt.c (register_local_specialization): Don't return a value.
authorMark Mitchell <mark@codesourcery.com>
Fri, 29 Dec 2000 06:08:00 +0000 (06:08 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 29 Dec 2000 06:08:00 +0000 (06:08 +0000)
* pt.c (register_local_specialization): Don't return a value.
(lookup_template_class): Use move-to-front heuristic when looking
up template instantiations.
(instantiate_decl): Only push_to_top_level when we're actually
going to instantiate the template.

From-SVN: r38524

gcc/cp/ChangeLog
gcc/cp/pt.c

index 92a8419ec7679ab38218c35bdb1a9e77cfeac504..2000fc225a66becd3e5bad21960c2c82a96230b3 100644 (file)
@@ -1,3 +1,11 @@
+2000-12-28  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (register_local_specialization): Don't return a value.
+       (lookup_template_class): Use move-to-front heuristic when looking
+       up template instantiations.
+       (instantiate_decl): Only push_to_top_level when we're actually
+       going to instantiate the template.
+
 2000-12-29  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * search.c (binfo_for_vtable): Return least derived class, not
index 0c4991a1a50763f9c525df552f2a607966799d46..29047d7306bb106d0115eb8fd00513d67f278d50 100644 (file)
@@ -128,7 +128,7 @@ static void push_inline_template_parms_recursive PARAMS ((tree, int));
 static tree retrieve_specialization PARAMS ((tree, tree));
 static tree retrieve_local_specialization PARAMS ((tree));
 static tree register_specialization PARAMS ((tree, tree, tree));
-static tree register_local_specialization PARAMS ((tree, tree));
+static void register_local_specialization PARAMS ((tree, tree));
 static int unregister_specialization PARAMS ((tree, tree));
 static tree reduce_template_parm_level PARAMS ((tree, tree, int));
 static tree build_template_decl PARAMS ((tree, tree));
@@ -923,7 +923,7 @@ unregister_specialization (spec, tmpl)
 /* Like register_specialization, but for local declarations.  We are
    registering SPEC, an instantiation of TMPL.  */
 
-static tree
+static void
 register_local_specialization (spec, tmpl)
      tree spec;
      tree tmpl;
@@ -932,8 +932,6 @@ register_local_specialization (spec, tmpl)
 
   slot = htab_find_slot (local_specializations, tmpl, INSERT);
   *slot = spec;
-
-  return spec;
 }
 
 /* Print the list of candidate FNS in an error message.  */
@@ -3842,6 +3840,7 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope)
       tree gen_tmpl;
       tree type_decl;
       tree found = NULL_TREE;
+      tree *tp;
       int arg_depth;
       int parm_depth;
       int is_partial_instantiation;
@@ -3956,11 +3955,19 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope)
        }
       if (found)
         return found;
-      
-      for (found = DECL_TEMPLATE_INSTANTIATIONS (template);
-          found; found = TREE_CHAIN (found))
-       if (comp_template_args (TREE_PURPOSE (found), arglist))
-          return TREE_VALUE (found);
+
+      for (tp = &DECL_TEMPLATE_INSTANTIATIONS (template);
+          *tp;
+          tp = &TREE_CHAIN (*tp))
+       if (comp_template_args (TREE_PURPOSE (*tp), arglist))
+         {
+           found = *tp;
+           *tp = TREE_CHAIN (*tp);
+           TREE_CHAIN (found) 
+             = DECL_TEMPLATE_INSTANTIATIONS (template);
+           DECL_TEMPLATE_INSTANTIATIONS (template) = found;
+           return TREE_VALUE (found);
+         }
 
       /* This type is a "partial instantiation" if any of the template
         arguments still involve template parameters.  Note that we set
@@ -9702,7 +9709,6 @@ instantiate_decl (d, defer_ok)
   else
     pattern_defined = ! DECL_IN_AGGR_P (code_pattern);
 
-  push_to_top_level ();
   lineno = DECL_SOURCE_LINE (d);
   input_filename = DECL_SOURCE_FILE (d);
 
@@ -9766,6 +9772,8 @@ instantiate_decl (d, defer_ok)
       goto out;
     }
 
+  push_to_top_level ();
+
   /* We're now committed to instantiating this template.  Mark it as
      instantiated so that recursive calls to instantiate_decl do not
      try to instantiate it again.  */
@@ -9828,11 +9836,12 @@ instantiate_decl (d, defer_ok)
   /* We're not deferring instantiation any more.  */
   TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (d)) = 0;
 
+  pop_from_top_level ();
+
 out:
   lineno = line;
   input_filename = file;
 
-  pop_from_top_level ();
   pop_tinst_level ();
 
   timevar_pop (TV_PARSE);