aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-04-02 22:20:43 -0400
committerJason Merrill <jason@redhat.com>2021-05-28 09:33:11 -0400
commit0f54cc9c63842ddfa921530cb499743cafc9b177 (patch)
tree28795686ae6679df3a4961d97f4d71e8d87d3cd1 /gcc/cp/semantics.c
parentf7a07f5a5d8065e7f11133dd1f4ad3510ab2195b (diff)
downloadgcc-0f54cc9c63842ddfa921530cb499743cafc9b177.zip
gcc-0f54cc9c63842ddfa921530cb499743cafc9b177.tar.gz
gcc-0f54cc9c63842ddfa921530cb499743cafc9b177.tar.bz2
tree-iterator: C++11 range-for and tree_stmt_iterator
Like my recent patch to add ovl_range and lkp_range in the C++ front end, this patch adds the tsi_range adaptor for using C++11 range-based 'for' with a STATEMENT_LIST, e.g. for (tree stmt : tsi_range (stmt_list)) { ... } This also involves adding some operators to tree_stmt_iterator that are needed for range-for iterators, and should also be useful in code that uses the iterators directly. The patch updates the suitable loops in the C++ front end, but does not touch any loops elsewhere in the compiler. gcc/ChangeLog: * tree-iterator.h (struct tree_stmt_iterator): Add operator++, operator--, operator*, operator==, and operator!=. (class tsi_range): New. gcc/cp/ChangeLog: * constexpr.c (build_data_member_initialization): Use tsi_range. (build_constexpr_constructor_member_initializers): Likewise. (constexpr_fn_retval, cxx_eval_statement_list): Likewise. (potential_constant_expression_1): Likewise. * coroutines.cc (await_statement_expander): Likewise. (await_statement_walker): Likewise. * module.cc (trees_out::core_vals): Likewise. * pt.c (tsubst_expr): Likewise. * semantics.c (set_cleanup_locs): Likewise.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index fe370a2..e40462d 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -613,9 +613,8 @@ set_cleanup_locs (tree stmts, location_t loc)
set_cleanup_locs (CLEANUP_BODY (stmts), loc);
}
else if (TREE_CODE (stmts) == STATEMENT_LIST)
- for (tree_stmt_iterator i = tsi_start (stmts);
- !tsi_end_p (i); tsi_next (&i))
- set_cleanup_locs (tsi_stmt (i), loc);
+ for (tree stmt : tsi_range (stmts))
+ set_cleanup_locs (stmt, loc);
}
/* Finish a scope. */