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.

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

Reply via email to