> On Oct 5, 2021, at 1:30 PM, Jason Merrill <ja...@redhat.com> wrote:
> 
>>> 'decl_had_value_expr_p' and check && !decl_had_value_expr_p here?
>>> So sth like
>> I can do this -:) I agree that the change will make the code simpler.
>> However, my major concern with this change is: later when people look at 
>> this change, they might ask:
>> Why we should not initialize a variable with VALUE_EXPR? And whether the 
>> variable whose VALUE_EXPR
>> was created by “gimplify_vla_decl” should be excluded?
>> My new function and comments were all for this purpose.
>> If I go with this change, at least we should add some comments to explain 
>> this as following, what do you think?
>>> 
>>> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
>>> index b27776af7c8..9013f385f13 100644
>>> --- a/gcc/gimplify.c
>>> +++ b/gcc/gimplify.c
>>> @@ -1872,6 +1872,7 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
>>>     {
>>>       tree init = DECL_INITIAL (decl);
>>>       bool is_vla = false;
>>    + /* Check whether a decl has FE created VALUE_EXPR here BEFORE
>>    +  gimplify_vla_decl creates VALUE_EXPR for vla decl.  */
>>> +      bool decl_had_value_expr_p = DECL_HAS_VALUE_EXPR_P (decl);
>>> 
>>>       poly_uint64 size;
>>>       if (!poly_int_tree_p (DECL_SIZE_UNIT (decl), &size)
>>> @@ -1934,7 +1935,8 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
>>>       /* When there is no explicit initializer, if the user requested,
>>>         We should insert an artifical initializer for this automatic
>>>         variable.  */
>>> -      else if (is_var_need_auto_init (decl))
>>> +      else if (is_var_need_auto_init (decl)
>> +   /* If the VAR_DECL has DECL_VALUE_EXPR that was created by FE (usually 
>> C++FE),
>> +   it's a proxy varaible, and FE already initializd the DECL_VALUE_EXPR of 
>> it. */
> 
> I'd suggest merging this comment into the comment on the variable declaration.

Okay, will merge these two comments into one and put it on the variable 
declaration.

thanks.

Qing

Reply via email to