This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][Middle-end]79538 missing -Wformat-overflow with %s and non-member array arguments
> On Dec 12, 2017, at 10:50 AM, Richard Biener <rguenther@suse.de> wrote:
>>>
>>>> + return false;
>>>> + val = fold_build2 (MINUS_EXPR, TREE_TYPE (val), val,
>>>> + integer_one_node);
>>>
>>> val = wide_int_to_tree (TREE_TYPE (val), wi::minus (wi::to_wide
>> (val), 1));
>
> I don't see this requested change.
>> + val = fold_build2 (MINUS_EXPR, TREE_TYPE (val), val,
>> + build_int_cst (TREE_TYPE (val), 1));
for my original code:
>>>> + val = fold_build2 (MINUS_EXPR, TREE_TYPE (val), val,
>>>> + integer_one_node);
I thought that your original major concern was:
“ you pass a possibly bogus type of 1 to fold_build2 above”
so I use “build_int_cst (TREE_TYPE (val), 1)" to replace the original “integer_one_node”
to make the type of the 1 exactly the same as “val”.
do I miss anything here?
I don’t quite understand why I have to use:
val = wide_int_to_tree (TREE_TYPE (val), wi::minus (wi::to_wide(val), 1));
to replace the original fold_build2 (MINUS_EXPR, TREE_TYPE (val), val, integer_one_node)?
thanks.
Qing
>> wide-int variant
>>> is prefered.
>>>
>>> The gimple-fold.c changes are ok with that change.
>>
>> Per your comments, the updated gimple-fold.c is like the following:
>>
>> diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
>> index 353a46e..0500fba 100644
>> --- a/gcc/gimple-fold.c
>> +++ b/gcc/gimple-fold.c
>> @@ -1323,6 +1323,19 @@ get_range_strlen (tree arg, tree length[2],
>> bitmap *visited, int type,
>> the array could have zero length. */
>> *minlen = ssize_int (0);
>> }
>> +
>> + if (VAR_P (arg)
>> + && TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE)
>> + {
>> + val = TYPE_SIZE_UNIT (TREE_TYPE (arg));
>> + if (!val || TREE_CODE (val) != INTEGER_CST ||
>> integer_zerop (val))
>> + return false;
>> + val = fold_build2 (MINUS_EXPR, TREE_TYPE (val), val,
>> + build_int_cst (TREE_TYPE (val), 1));
>> + /* Set the minimum size to zero since the string in
>> + the array could have zero length. */
>> + *minlen = ssize_int (0);
>> + }
>> }
>>
>> if (!val)
>>
>> let me know any further issue with the above.
>>
>> thanks a lot.
>>
>> Qing