On Fri, Feb 25, 2022 at 11:12:13AM +0100, Richard Biener wrote: > On Fri, 25 Feb 2022, Jakub Jelinek wrote: > > > 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? > > Yes. Depending on the context tmp_dst will already reliably have > UNKNOWN_LOCATION? If tmp_dst might be a plain decl we have to > be more careful of course.
tmp_dst is: tree dst = build2_loc (buf->loc, MEM_REF, atype, buf->base, build_int_cst (buf->alias_type, off)); ... tmp_dst = unshare_expr (dst); We could build2 the dst and set its location only after unshare_expr too, but I guess clearing it with a comment on why we do that is better. Jakub