On Wed, Mar 26, 2025 at 7:22 AM Andrew Pinski <pins...@gmail.com> wrote: > > On Tue, Mar 25, 2025 at 10:59 PM Richard Biener > <richard.guent...@gmail.com> wrote: > > > > > > > > > Am 26.03.2025 um 04:47 schrieb Andrew Pinski <quic_apin...@quicinc.com>: > > > > > > This adds a simple verification so that the LHS of an assignment is > > > not a function decl. SRA and FRE will produce an ICE for this anyways > > > so let's catch it earlier. This showed up because the fortran front-end > > > didn't translate the function name into the result decl in some cases. > > > > > > Bootstrapped and tested on x86_64_linux-gnu with no regressions. > > > > Why is the is_gimple_val test not catching this? > > Because verify_gimple_assign_single does not check is_gimple_val. So > maybe this should moved into verify_gimple_assign_single instead of > where I placed it.
Hmm, yeah - it only calls verify_types_in_gimple_reference for handled components and indirections. I think we should call this for all non-register LHS. Note I'm not 100% sure writing to a FUNCTION_DECL should be invalid GIMPLE, at least when wrapped in a MEM_REF. But yes, a FUNCTION_DECL or also a LABEL_DECL directly appearing as part of a value should be invalid. Note that even f.a should be invalid and detected. verify_types_in_gimple_reference is the vehicle that's designed to verify what's a valid reference (those might appear elsewhere, like in calls) Richard. > Thanks, > Andrew > > > > > > > > > gcc/ChangeLog: > > > > > > PR middle-end/118796 > > > * tree-cfg.cc (verify_gimple_assign): Verify the lhs is not > > > a function decl. > > > > > > Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com> > > > --- > > > gcc/tree-cfg.cc | 9 +++++++++ > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc > > > index 2fa5678051a..f25480cf6fc 100644 > > > --- a/gcc/tree-cfg.cc > > > +++ b/gcc/tree-cfg.cc > > > @@ -4840,6 +4840,15 @@ verify_gimple_assign_single (gassign *stmt) > > > static bool > > > verify_gimple_assign (gassign *stmt) > > > { > > > + tree lhs = gimple_assign_lhs (stmt); > > > + > > > + if (TREE_CODE (lhs) == FUNCTION_DECL) > > > + { > > > + error ("lhs cannot be a function"); > > > + debug_generic_stmt (lhs); > > > + return true; > > > + } > > > + > > > if (gimple_assign_nontemporal_move_p (stmt)) > > > { > > > tree lhs = gimple_assign_lhs (stmt); > > > -- > > > 2.43.0 > > >