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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> This patch prevents the ICE.

The patch is mostly good, but does not set the errmsg variable, which
leads to garbage in the printed error message.

We could do the following (haven't found a better one yet):

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index 73799c175b7..ad4182a01ae 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -1334,6 +1334,12 @@ gfc_check_dummy_characteristics (gfc_symbol *s1,
gfc_symbol *s2,
   if (s1 == NULL || s2 == NULL)
     return s1 == s2 ? true : false;

+  if (s1->attr.proc == PROC_ST_FUNCTION || s2->attr.proc == PROC_ST_FUNCTION)
+    {
+      strncpy (errmsg, "Statement function", err_len);
+      return false;
+    }
+
   /* Check type and rank.  */
   if (type_must_agree)
     {

This prints:

pr107995-z1.f90:4:3:

    4 |   n(n) = 1
      |   1
Error: Self-referential argument 'n' at (1) is not allowed
pr107995-z1.f90:5:13:

    5 |   print *, n(n)
      |             1
Error: Statement function 'n' at (1) is not allowed as an actual argument
pr107995-z1.f90:5:13:

    5 |   print *, n(n)
      |             1
Error: Interface mismatch in dummy procedure 'n' at (1): Statement function

Reply via email to