Commit 707df8ad by Adam Butcher Committed by Adam Butcher

Use translation-unit-global rather than parameter-list-local counter for generic…

Use translation-unit-global rather than parameter-list-local counter for generic type names to facilitate nested implicit function templates.

	* parser.c (make_generic_type_name): Use global count rather than
	parameter and ...
	(add_implicit_template_parms): ... propagate interface change here.

From-SVN: r202847
parent 5e8586d7
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> 2013-09-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58481 PR c++/58481
......
...@@ -28897,11 +28897,12 @@ c_parse_file (void) ...@@ -28897,11 +28897,12 @@ c_parse_file (void)
/* Create an identifier for a generic parameter type (a synthesized /* Create an identifier for a generic parameter type (a synthesized
template parameter implied by `auto' or a concept identifier). */ template parameter implied by `auto' or a concept identifier). */
static GTY(()) int generic_parm_count;
static tree static tree
make_generic_type_name (int i) make_generic_type_name ()
{ {
char buf[32]; char buf[32];
sprintf (buf, "__GenT%d", i); sprintf (buf, "__GenT%d", ++generic_parm_count);
return get_identifier (buf); return get_identifier (buf);
} }
...@@ -28915,14 +28916,14 @@ tree_type_is_auto_or_concept (const_tree t) ...@@ -28915,14 +28916,14 @@ tree_type_is_auto_or_concept (const_tree t)
return TREE_TYPE (t) && is_auto_or_concept (TREE_TYPE (t)); return TREE_TYPE (t) && is_auto_or_concept (TREE_TYPE (t));
} }
/* Add COUNT implicit template parameters gleaned from the generic /* Add EXPECT_COUNT implicit template parameters gleaned from the generic
type parameters in PARAMETERS to the CURRENT_TEMPLATE_PARMS type parameters in PARAMETERS to the CURRENT_TEMPLATE_PARMS (creating a new
(creating a new template parameter list if necessary). Returns template parameter list if necessary). Returns PARAMETERS suitably rewritten
PARAMETERS suitably rewritten to reference the newly created types to reference the newly created types or ERROR_MARK_NODE on failure. */
or ERROR_MARK_NODE on failure. */
tree 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); 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) ...@@ -28931,7 +28932,7 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
bool become_template = bool become_template =
fn_parms_scope->level_chain->kind != sk_template_parms; 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 /* 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 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) ...@@ -28973,7 +28974,7 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
++processing_template_parmlist; ++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 tree generic_type_ptr
= find_type_usage (TREE_VALUE (p), tree_type_is_auto_or_concept); = 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) ...@@ -28981,7 +28982,9 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
if (!generic_type_ptr) if (!generic_type_ptr)
continue; 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, tree synth_tmpl_parm = finish_template_type_parm (class_type_node,
synth_id); synth_id);
tparms = process_template_parm (tparms, DECL_SOURCE_LOCATION (TREE_VALUE 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) ...@@ -29004,7 +29007,7 @@ add_implicit_template_parms (cp_parser *parser, size_t count, tree parameters)
cur_type = new_type; cur_type = new_type;
} }
gcc_assert (synth_idx == count); gcc_assert (synth_count == expect_count);
push_binding_level (fn_parms_scope); push_binding_level (fn_parms_scope);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment