https://gcc.gnu.org/g:330ad1d700bc01df21996685770bff484b0c4d21

commit 330ad1d700bc01df21996685770bff484b0c4d21
Author: Mikael Morin <[email protected]>
Date:   Mon Sep 28 14:23:57 2026 +0200

    Correction régression allocate_with_source_16

Diff:
---
 gcc/fortran/primary.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index 35f22da8ab39..2b34e0bece49 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -3041,6 +3041,17 @@ gfc_variable_attr (gfc_expr *expr)
   attr = sym->attr;
   current_ts = &sym->ts;
 
+  /* If we are in the body of a function, the reference to the function name
+     is the function result, not the function itself.  */
+  if (attr.function
+      && sym->result == sym
+      && gfc_current_ns
+      && gfc_current_ns->proc_name == sym)
+    {
+      attr.function = 0;
+      attr.flavor = FL_VARIABLE;
+    }
+
   optional = attr.optional;
   if (sym->ts.type == BT_CLASS && sym->attr.class_ok && sym->ts.u.derived)
     {

Reply via email to