On Thu, Feb 24, 2022 at 04:00:33PM +0100, Richard Biener wrote:
> > > --- 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.
> 
> Maybe that's something suppress_warning should do then?  OTOH you

Well, OPT_Wuninitialized is an argument why it can't.  The suppression
is using a single OPT_W*, but there are multiple different warnings
that care about that suppression, and suppress_warning can't know about it.

> don't know whether you're suppressing a warning in a region with
> -Wno-uninitialized but that's inlined into a -Wuninitialized
> function where then the false diagnostic pops up if we didn't
> suppress the warning ...

I think both -Wuninitialized and -Wmaybe-uninitialized aren't
Optimization or PerFunction, so they are global options.
On the other side, they can be locally changed through pragmas.

Maybe we could use
  if (warning_enabled_at (buf->loc, OPT_Wuninitialized)
      || warning_enabled_at (buf->loc, OPT_Wmaybe_uninitialized))
if uninit pass uses the gimple_location of the read, that shouldn't
be really changing...

        Jakub

Reply via email to