The PRs originated in gfc_element_size lacking a treatment of
procedure pointers, which has been added.  The testcase is currently
a pure compile test.  When a reduced run-time test for PR83515
becomes available, it will be added to the testsuite.

Regtested on x86_64-pc-linux-gnu.

OK for trunk?

Thanks,
Harald

2019-03-20  Harald Anlauf  <anl...@gmx.de>

        PR fortran/83515
        PR fortran/85797
        * trans-types.c (gfc_typenode_for_spec): Handle conversion for
        procedure pointers.
        * target-memory.c (gfc_element_size): Handle size determination
        for procedure pointers.

2019-03-20  Harald Anlauf  <anl...@gmx.de>

        PR fortran/83515
        PR fortran/85797
        * gfortran.dg/pr85797.f90: New test.

Index: gcc/fortran/target-memory.c
===================================================================
--- gcc/fortran/target-memory.c (revision 269826)
+++ gcc/fortran/target-memory.c (working copy)
@@ -120,6 +120,7 @@
     case BT_CLASS:
     case BT_VOID:
     case BT_ASSUMED:
+    case BT_PROCEDURE:
       {
        /* Determine type size without clobbering the typespec for ISO C
           binding types.  */
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c   (revision 269826)
+++ gcc/fortran/trans-types.c   (working copy)
@@ -1194,6 +1194,9 @@
            basetype = pfunc_type_node;
        }
        break;
+    case BT_PROCEDURE:
+      basetype = pfunc_type_node;
+      break;
     default:
       gcc_unreachable ();
     }
Index: gcc/testsuite/gfortran.dg/pr85797.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr85797.f90       (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr85797.f90       (working copy)
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-options "-Wall" }
+! PR fortran/83515 - ICE: Invalid expression in gfc_element_size
+! PR fortran/85797 - ICE in gfc_element_size, at fortran/target-memory.c:126
+
+subroutine a
+  c = transfer (a, b)           ! { dg-warning "Non-RECURSIVE procedure" }
+end
+
+recursive subroutine d
+  c = transfer (d, b)
+end
+
+recursive subroutine e
+  k = transfer (transfer (e, e), 1)
+end
+
+subroutine f
+  use, intrinsic :: iso_c_binding
+  integer(c_intptr_t) :: b, c
+  c = transfer (transfer (b, a), b)
+end
+
+module m
+contains
+  function f () result (z)      ! { dg-warning "Return value" }
+    class(*), pointer :: z
+  end function f
+  recursive subroutine s (q)
+    procedure(f) :: q
+    call s (q)
+  end subroutine s
+end

Reply via email to