On Thu, Feb 24, 2022 at 02:30:05PM +0000, Qing Zhao wrote:
>       PR middle-end/104550
> 
> gcc/ChangeLog:
> 
>       * gimple-fold.cc (clear_padding_flush): Suppress warnings for new
>       created uses.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/auto-init-pr104550-1.c: New test.
>       * gcc.dg/auto-init-pr104550-2.c: New test.
>       * gcc.dg/auto-init-pr104550-3.c: New test.
> ---
>  gcc/gimple-fold.cc                          |  7 ++++++-
>  gcc/testsuite/gcc.dg/auto-init-pr104550-1.c | 10 ++++++++++
>  gcc/testsuite/gcc.dg/auto-init-pr104550-2.c | 11 +++++++++++
>  gcc/testsuite/gcc.dg/auto-init-pr104550-3.c | 11 +++++++++++
>  4 files changed, 38 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-1.c
>  create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-3.c
> 
> diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
> index 16f02c2d098..e11a775ad9f 100644
> --- a/gcc/gimple-fold.cc
> +++ b/gcc/gimple-fold.cc
> @@ -4379,7 +4379,12 @@ clear_padding_flush (clear_padding_struct *buf, bool 
> full)
>             else
>               {
>                 src = make_ssa_name (type);
> -               g = gimple_build_assign (src, unshare_expr (dst));
> +               tree tmp_dst = unshare_expr (dst);
> +               /* The folding introduces a read from the tmp_dst, we should
> +                  prevent uninitialized warning analysis from issuing warning
> +                  for such fake read.  */
> +               suppress_warning (tmp_dst, OPT_Wuninitialized);

I wonder if we shouldn't guard the suppress_warning call on
                  if (warn_uninitialized || warn_maybe_uninitialized)
because those warnings aren't on by default and the suppress_warning stuff,
especially when it could be done for many loads from the builtin means
populating hash tables with those.

Otherwise LGTM.

        Jakub

Reply via email to