diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2022-04-29 17:54:39 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2022-04-29 17:54:39 +0100 |
commit | 3e5f7ca352c26a222bb588741b7c700a3052a372 (patch) | |
tree | 283aec084274668fe34c23c49ab2999390ed9778 /gcc/cp/tree.cc | |
parent | 2ce0608ca3dca30518bec525c435f7bc4d7f9b70 (diff) | |
parent | b85e79dce149df68b92ef63ca2a40ff1dfa61396 (diff) | |
download | gcc-devel/c++-coroutines.tar.gz |
Merge master r12-8312.devel/c++-coroutines
* Merge master r12-8312-gb85e79dce149.
Diffstat (limited to 'gcc/cp/tree.cc')
-rw-r--r-- | gcc/cp/tree.cc | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 780a8d89165..ed0d0d22950 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -740,7 +740,7 @@ build_cplus_new (tree type, tree init, tsubst_flags_t complain) constructor calls until gimplification time; now we only do it to set VEC_INIT_EXPR_IS_CONSTEXPR. - We assume that init is either NULL_TREE, void_type_node (indicating + We assume that init is either NULL_TREE, {}, void_type_node (indicating value-initialization), or another array to copy. */ static tree @@ -752,7 +752,20 @@ build_vec_init_elt (tree type, tree init, tsubst_flags_t complain) || !CLASS_TYPE_P (inner_type)) /* No interesting initialization to do. */ return integer_zero_node; - else if (init == void_type_node) + if (init && BRACE_ENCLOSED_INITIALIZER_P (init)) + { + /* Even if init has initializers for some array elements, + we're interested in the {}-init of trailing elements. */ + if (CP_AGGREGATE_TYPE_P (inner_type)) + { + tree empty = build_constructor (init_list_type_node, nullptr); + return digest_init (inner_type, empty, complain); + } + else + /* It's equivalent to value-init. */ + init = void_type_node; + } + if (init == void_type_node) return build_value_init (inner_type, complain); releasing_vec argvec; @@ -808,9 +821,13 @@ build_vec_init_expr (tree type, tree init, tsubst_flags_t complain) TREE_SIDE_EFFECTS (init) = true; SET_EXPR_LOCATION (init, input_location); - if (cxx_dialect >= cxx11 - && potential_constant_expression (elt_init)) - VEC_INIT_EXPR_IS_CONSTEXPR (init) = true; + if (cxx_dialect >= cxx11) + { + bool cx = potential_constant_expression (elt_init); + if (BRACE_ENCLOSED_INITIALIZER_P (init)) + cx &= potential_constant_expression (init); + VEC_INIT_EXPR_IS_CONSTEXPR (init) = cx; + } VEC_INIT_EXPR_VALUE_INIT (init) = value_init; return init; @@ -1566,7 +1583,8 @@ apply_identity_attributes (tree result, tree attribs, bool *remove_attributes) stripped. */ tree -strip_typedefs (tree t, bool *remove_attributes, unsigned int flags) +strip_typedefs (tree t, bool *remove_attributes /* = NULL */, + unsigned int flags /* = 0 */) { tree result = NULL, type = NULL, t0 = NULL; |