aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Butcher <adam@jessamine.co.uk>2013-09-23 23:43:06 +0100
committerAdam Butcher <abutcher@gcc.gnu.org>2013-09-23 23:43:06 +0100
commit707df8ad64e1ded5a1d0b29af6abc43acb7b9a3e (patch)
tree3fb82c1510cbd98174829e68b18c4124f4149cd9
parent5e8586d720eb9481a09cbe07eb40590fbc86c89f (diff)
downloadgcc-707df8ad64e1ded5a1d0b29af6abc43acb7b9a3e.zip
gcc-707df8ad64e1ded5a1d0b29af6abc43acb7b9a3e.tar.gz
gcc-707df8ad64e1ded5a1d0b29af6abc43acb7b9a3e.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c27
2 files changed, 21 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a542ab1..7de3018 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 2cd60f0..fac3808 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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);