https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100154

--- Comment #7 from anlauf at gcc dot gnu.org ---
(In reply to Tobias Burnus from comment #4)
> as ptr_returning_func() (a function reference with data pointer result) is a
> variable in the sense of the Fortran standard (F2018:R902)?

Do you think the following is the right thing?

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 82db8e4e1b2..2c34c2b6786 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1055,6 +1055,12 @@ variable_check (gfc_expr *e, int n, bool allow_proc)
          return true;
     }

+  /* F2018:R902: function pointer having a data pointer result.  */
+  if (e->expr_type == EXPR_FUNCTION
+      && e->symtree->n.sym->attr.flavor == FL_PROCEDURE
+      && e->symtree->n.sym->attr.pointer)
+    return true;
+
   gfc_error ("%qs argument of %qs intrinsic at %L must be a variable",
             gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic,
&e->where);


That is sort of independent of the other parts of the patch, but would be
needed for a full fix.

Reply via email to