aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorAdam Butcher <adam@jessamine.co.uk>2013-11-12 20:17:33 +0000
committerAdam Butcher <abutcher@gcc.gnu.org>2013-11-12 20:17:33 +0000
commit0dca5025f02ad920b12cede50c7968768decee19 (patch)
treedd7d73f2767b4b7b3797611c8cc9aea5b69ed13d /gcc/tree.c
parent27297d2d1b7731db604400f335e4653da7c09a22 (diff)
downloadgcc-0dca5025f02ad920b12cede50c7968768decee19.zip
gcc-0dca5025f02ad920b12cede50c7968768decee19.tar.gz
gcc-0dca5025f02ad920b12cede50c7968768decee19.tar.bz2
Refactor implicit function template implementation and fix 58534, 58536, 58548, 58549 and 58637.
gcc/ * tree.c (grow_tree_vec_stat): New function ... * tree.h (grow_tree_vec_stat) (grow_tree_vec): ... and its declaration and macro front-end. gcc/cp/ PR c++/58534 PR c++/58536 PR c++/58548 PR c++/58549 PR c++/58637 * parser.h (struct cp_parser): New members implicit_template_parms, implicit_template_scope and auto_is_implicit_function_template_parm_p. * parser.c (add_implicit_template_parms): Refactor as ... (synthesize_implicit_template_parm): ... this to append a new template type parm to the current template parameter list (introducing a new list if necessary). Removed push_deferring_access_checks. (finish_fully_implicit_template): Removed pop_deferring_access_checks. (cp_parser_new): Initialize new cp_parser members. (cp_parser_parameter_declaration_clause): Consider auto as implicit template parm when parsing a parameter declaration (unless parsing an explicit specialization). (cp_parser_parameter_declaration_list): Remove local implicit_template_parms counter and reset cp_parser implicit template state when complete. (cp_parser_lambda_expression): Reset implicit template cp_parser members whilst generating lambda class. (cp_parser_function_definition_after_declarator): Reset implicit template cp_parser members whilst parsing function definition. (make_generic_type_name): Respell '<autoN>' as 'auto:N' which works better with template diagnostics. (cp_parser_simple_type_specifier): Synthesize implicit template parm on parsing 'auto' if auto_is_implicit_function_template_parm_p and provide diagnostics ... * decl.c (grokdeclarator): ... that were previously done here. gcc/testsuite/g++.dg/ * cpp1y/pr58534.C: New testcase. * cpp1y/pr58536.C: New testcase. * cpp1y/pr58548.C: New testcase. * cpp1y/pr58549.C: New testcase. * cpp1y/pr58637.C: New testcase. From-SVN: r204714
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 686a680..dd0371d 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1864,6 +1864,28 @@ make_tree_vec_stat (int len MEM_STAT_DECL)
return t;
}
+
+/* Grow a TREE_VEC node to new length LEN. */
+
+tree
+grow_tree_vec_stat (tree v, int len MEM_STAT_DECL)
+{
+ gcc_assert (TREE_CODE (v) == TREE_VEC);
+
+ int oldlen = TREE_VEC_LENGTH (v);
+ gcc_assert (len > oldlen);
+
+ int oldlength = (oldlen - 1) * sizeof (tree) + sizeof (struct tree_vec);
+ int length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
+
+ record_node_allocation_statistics (TREE_VEC, length - oldlength);
+
+ v = (tree) ggc_realloc_stat (v, length PASS_MEM_STAT);
+
+ TREE_VEC_LENGTH (v) = len;
+
+ return v;
+}
/* Return 1 if EXPR is the integer constant zero or a complex constant
of zero. */