/* 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);
}
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);
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
++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);
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
cur_type = new_type;
}
- gcc_assert (synth_idx == count);
+ gcc_assert (synth_count == expect_count);
push_binding_level (fn_parms_scope);