aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-12-02 17:11:33 -0500
committerJason Merrill <jason@redhat.com>2020-12-04 14:45:25 -0500
commitdf933e307b1950ce12472660dcac1765b8eb431d (patch)
tree6eeefb7f2051c8c3525431d0e35f8b5668922172 /gcc/cp/parser.c
parentb96802994acb47d5a86d9112d7b1eeda9418827f (diff)
downloadgcc-df933e307b1950ce12472660dcac1765b8eb431d.zip
gcc-df933e307b1950ce12472660dcac1765b8eb431d.tar.gz
gcc-df933e307b1950ce12472660dcac1765b8eb431d.tar.bz2
vec: Simplify use with C++11 range-based 'for'.
It looks cleaner if we can use a vec* directly as a range for the C++11 range-based 'for' loop, without needing to indirect from it, and also works with null pointers. The change in cp_parser_late_parsing_default_args is an example of how this can be used to simplify a simple loop over a vector. Reverse or subset iteration will require adding range adaptors. I deliberately didn't format the new overloads for etags since they are trivial. gcc/ChangeLog: * vec.h (begin, end): Add overloads for vec*. * tree.c (build_constructor_from_vec): Remove *. gcc/cp/ChangeLog: * decl2.c (clear_consteval_vfns): Remove *. * pt.c (do_auto_deduction): Remove *. * parser.c (cp_parser_late_parsing_default_args): Change loop to use range 'for'.
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 103567c..cc3da15 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -30611,9 +30611,6 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
{
tree default_arg = TREE_PURPOSE (parm);
tree parsed_arg;
- vec<tree, va_gc> *insts;
- tree copy;
- unsigned ix;
tree parmdecl = parms[i];
pushdecl (parmdecl);
@@ -30633,8 +30630,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
TREE_PURPOSE (parm) = parsed_arg;
/* Update any instantiations we've already created. */
- for (insts = DEFPARSE_INSTANTIATIONS (default_arg), ix = 0;
- vec_safe_iterate (insts, ix, &copy); ix++)
+ for (tree copy : DEFPARSE_INSTANTIATIONS (default_arg))
TREE_PURPOSE (copy) = parsed_arg;
}