On Fri, 25 Feb 2022, Jakub Jelinek wrote:

> On Fri, Feb 25, 2022 at 10:13:33AM +0100, Richard Biener via Gcc-patches 
> wrote:
> > I meant
> > 
> > /* Set the no_warning flag of STMT to NO_WARNING.  */
> > 
> > static inline void
> > gimple_set_no_warning (gimple *stmt, bool no_warning)
> > {
> >   stmt->no_warning = (unsigned) no_warning;
> > }
> > 
> > on the artificial stmt.
> 
> That seems to be the same case as TREE_NO_WARNING, all those calls
> have been replaced:
> $ grep -w gimple_set_no_warning *.{h,cc} */*.{h,cc}
> gimple.h:gimple_set_no_warning (gimple *stmt, bool no_warning)
> 
> But perhaps it is a good idea to start using that when the location_t
> isn't a good idea to use for suppression.

I think it's used as fallback for UNKNOWN_LOCATION, but if we "invent"
a creative location for the artificial stmt it will of course
affect other stmts/expressions using that location.

> I think it will work.

Yes, I think so.  OTOH the uninit pass does

  /* Avoid warning if we've already done so or if the warning has been
     suppressed.  */
  if (((warning_suppressed_p (context, OPT_Wuninitialized)
        || (gimple_assign_single_p (context)
            && get_no_uninit_warning (gimple_assign_rhs1 (context)))))
      || (var && get_no_uninit_warning (var))
      || (var_name_str
          && warning_suppressed_p (var_def_stmt, OPT_Wuninitialized)))
    return;

that's a mightly complicated way to test and I'm not sure we get
to the bit on the stmt reliably.  So maybe TREE_NO_WARNING on the
reference (or making sure it has UNKNOWN_LOCATION and using
suppress_warning on it) is a better idea after all...

Richard.

Reply via email to