Use translation-unit-global rather than parameter-list-local counter for generic...
authorAdam Butcher <adam@jessamine.co.uk>
Mon, 23 Sep 2013 22:43:06 +0000 (23:43 +0100)
committerAdam Butcher <abutcher@gcc.gnu.org>
Mon, 23 Sep 2013 22:43:06 +0000 (23:43 +0100)
* parser.c (make_generic_type_name): Use global count rather than
parameter and ...
(add_implicit_template_parms): ... propagate interface change here.

From-SVN: r202847

gcc/cp/ChangeLog
gcc/cp/parser.c

index a542ab1..7de3018 100644 (file)
@@ -1,3 +1,9 @@
+2013-09-23  Adam Butcher  <adam@jessamine.co.uk>
+
+       * parser.c (make_generic_type_name): Use global count rather than
+       parameter and ...
+       (add_implicit_template_parms): ... propagate interface change here.
+
 2013-09-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58481
index 2cd60f0..fac3808 100644 (file)
@@ -28897,11 +28897,12 @@ c_parse_file (void)
 /* Create an identifier for a generic parameter type (a synthesized
    template parameter implied by `auto' or a concept identifier). */
 
+static GTY(()) int generic_parm_count;
 static tree
-make_generic_type_name (int i)
+make_generic_type_name ()
 {
   char buf[32];
-  sprintf (buf, "__GenT%d", i);
+  sprintf (buf, "__GenT%d", ++generic_parm_count);
   return get_identifier (buf);
 }
 
@@ -28915,14 +28916,14 @@ tree_type_is_auto_or_concept (const_tree t)
   return TREE_TYPE (t) && is_auto_or_concept (TREE_TYPE (t));
 }
 
-/* Add COUNT implicit template parameters gleaned from the generic
-   type parameters in PARAMETERS to the CURRENT_TEMPLATE_PARMS
-   (creating a new template parameter list if necessary).  Returns
-   PARAMETERS suitably rewritten to reference the newly created types
-   or ERROR_MARK_NODE on failure.  */
+/* Add EXPECT_COUNT implicit template parameters gleaned from the generic
+   type parameters in PARAMETERS to the CURRENT_TEMPLATE_PARMS (creating a new
+   template parameter list if necessary).  Returns PARAMETERS suitably rewritten
+   to reference the newly created types or ERROR_MARK_NODE on failure.  */
 
 tree
-add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
+add_implicit_template_parms (cp_parser *parser, size_t expect_count,
+                            tree parameters)
 {
   gcc_assert (current_binding_level->kind == sk_function_parms);
 
@@ -28931,7 +28932,7 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
   bool become_template =
     fn_parms_scope->level_chain->kind != sk_template_parms;
 
-  size_t synth_idx = 0;
+  size_t synth_count = 0;
 
   /* Roll back a scope level and either introduce a new template parameter list
      or update an existing one.  The function scope is added back after template
@@ -28973,7 +28974,7 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
       ++processing_template_parmlist;
     }
 
-  for (tree p = parameters; p && synth_idx < count; p = TREE_CHAIN (p))
+  for (tree p = parameters; p && synth_count < expect_count; p = TREE_CHAIN (p))
     {
       tree generic_type_ptr
        = find_type_usage (TREE_VALUE (p), tree_type_is_auto_or_concept);
@@ -28981,7 +28982,9 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
       if (!generic_type_ptr)
        continue;
 
-      tree synth_id = make_generic_type_name (synth_idx++);
+      ++synth_count;
+
+      tree synth_id = make_generic_type_name ();
       tree synth_tmpl_parm = finish_template_type_parm (class_type_node,
                                                        synth_id);
       tparms = process_template_parm (tparms, DECL_SOURCE_LOCATION (TREE_VALUE
@@ -29004,7 +29007,7 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
        cur_type = new_type;
     }
 
-  gcc_assert (synth_idx == count);
+  gcc_assert (synth_count == expect_count);
 
   push_binding_level (fn_parms_scope);