* parser.c (make_generic_type_name): Use static count rather than parameter and ... (add_implicit_template_parms): ... propagate interface change here. --- gcc/cp/parser.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 2cd60f0..7e9ade2 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -28898,9 +28898,10 @@ c_parse_file (void) template parameter implied by `auto' or a concept identifier). */ static tree -make_generic_type_name (int i) +make_generic_type_name () { char buf[32]; + static int i = 0; sprintf (buf, "__GenT%d", i); 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); -- 1.8.4