aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-10-23 05:45:02 -0400
committerJason Merrill <jason@redhat.com>2021-11-04 11:35:54 -0400
commitfae00a0ac0e5687343a60ae02bf60352002ab9aa (patch)
treeb929b52de9cd73a11c5fcf2848b8ea23a84e009d /gcc/cp/constexpr.c
parenteb04ccf4bfd6586cf0d22d439de28a4e6c649182 (diff)
downloadgcc-fae00a0ac0e5687343a60ae02bf60352002ab9aa.zip
gcc-fae00a0ac0e5687343a60ae02bf60352002ab9aa.tar.gz
gcc-fae00a0ac0e5687343a60ae02bf60352002ab9aa.tar.bz2
c++: use range-for more
gcc/cp/ChangeLog: * call.c (build_array_conv): Use range-for. (build_complex_conv): Likewise. * constexpr.c (clear_no_implicit_zero) (reduced_constant_expression_p): Likewise. * decl.c (cp_complete_array_type): Likewise. * decl2.c (mark_vtable_entries): Likewise. * pt.c (iterative_hash_template_arg): (invalid_tparm_referent_p, unify) (type_dependent_expression_p): Likewise. * typeck.c (build_ptrmemfunc_access_expr): Likewise.
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 40fe165..453007c 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1831,10 +1831,9 @@ clear_no_implicit_zero (tree ctor)
if (CONSTRUCTOR_NO_CLEARING (ctor))
{
CONSTRUCTOR_NO_CLEARING (ctor) = false;
- tree elt; unsigned HOST_WIDE_INT idx;
- FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), idx, elt)
- if (TREE_CODE (elt) == CONSTRUCTOR)
- clear_no_implicit_zero (elt);
+ for (auto &e: CONSTRUCTOR_ELTS (ctor))
+ if (TREE_CODE (e.value) == CONSTRUCTOR)
+ clear_no_implicit_zero (e.value);
}
}
@@ -2950,7 +2949,7 @@ reduced_constant_expression_p (tree t)
case CONSTRUCTOR:
/* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */
- tree idx, val, field; unsigned HOST_WIDE_INT i;
+ tree field;
if (CONSTRUCTOR_NO_CLEARING (t))
{
if (TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
@@ -2964,14 +2963,14 @@ reduced_constant_expression_p (tree t)
tree min = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (t)));
tree max = TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (t)));
tree cursor = min;
- FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), i, idx, val)
+ for (auto &e: CONSTRUCTOR_ELTS (t))
{
- if (!reduced_constant_expression_p (val))
+ if (!reduced_constant_expression_p (e.value))
return false;
- if (array_index_cmp (cursor, idx) != 0)
+ if (array_index_cmp (cursor, e.index) != 0)
return false;
- if (TREE_CODE (idx) == RANGE_EXPR)
- cursor = TREE_OPERAND (idx, 1);
+ if (TREE_CODE (e.index) == RANGE_EXPR)
+ cursor = TREE_OPERAND (e.index, 1);
cursor = int_const_binop (PLUS_EXPR, cursor, size_one_node);
}
if (find_array_ctor_elt (t, max) == -1)
@@ -2992,14 +2991,14 @@ reduced_constant_expression_p (tree t)
}
else
field = NULL_TREE;
- FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), i, idx, val)
+ for (auto &e: CONSTRUCTOR_ELTS (t))
{
/* If VAL is null, we're in the middle of initializing this
element. */
- if (!reduced_constant_expression_p (val))
+ if (!reduced_constant_expression_p (e.value))
return false;
/* Empty class field may or may not have an initializer. */
- for (; field && idx != field;
+ for (; field && e.index != field;
field = next_initializable_field (DECL_CHAIN (field)))
if (!is_really_empty_class (TREE_TYPE (field),
/*ignore_vptr*/false))