c: Support C2x empty initializer braces
Jakub Jelinek
jakub@redhat.com
Thu Aug 25 18:28:22 GMT 2022
On Thu, Aug 25, 2022 at 05:33:02PM +0000, Joseph Myers wrote:
> * gimplify.cc (gimplify_modify_expr): Convert initialization from
> a variable-size CONSTRUCTOR to memset before call to
> gimplify_modify_expr_rhs.
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -6031,6 +6031,21 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
> return GS_ALL_DONE;
> }
>
> + /* Convert initialization from an empty variable-size CONSTRUCTOR to
> + memset. */
> + if (TREE_TYPE (*from_p) != error_mark_node
> + && TYPE_SIZE_UNIT (TREE_TYPE (*from_p))
> + && !poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (*from_p)))
> + && TREE_CODE (*from_p) == CONSTRUCTOR
> + && vec_safe_is_empty (CONSTRUCTOR_ELTS (*from_p)))
Perhaps
&& CONSTRUCTOR_NELTS (*from_p) == 0)
instead?
> + {
> + maybe_with_size_expr (from_p);
The indentation above is 8 spaces instead of tab.
> + gcc_assert (TREE_CODE (*from_p) == WITH_SIZE_EXPR);
> + return gimplify_modify_expr_to_memset (expr_p,
> + TREE_OPERAND (*from_p, 1),
> + want_value, pre_p);
> + }
> +
Otherwise LGTM.
Jakub
More information about the Gcc-patches
mailing list