On Fri, Feb 25, 2022 at 10:31:50AM +0100, Richard Biener wrote:
> 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...
So
SET_EXPR_LOCATION (tmp_dst, UNKNOWN_LOCATION);
suppress_warning (tmp_dst, OPT_Wuninitialized);
with a comment explaing why we do that?
LGTM.
Jakub