]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/83515 (ICE: Invalid expression in gfc_element_size)
authorHarald Anlauf <anlauf@gmx.de>
Sun, 31 Mar 2019 19:21:37 +0000 (19:21 +0000)
committerHarald Anlauf <anlauf@gcc.gnu.org>
Sun, 31 Mar 2019 19:21:37 +0000 (19:21 +0000)
2019-03-31  Harald Anlauf  <anlauf@gmx.de>

Backport from trunk
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.

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

From-SVN: r270047

gcc/fortran/ChangeLog
gcc/fortran/target-memory.c
gcc/fortran/trans-types.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr85797.f90 [new file with mode: 0644]

index 03ae0852d41801a0d8b3125abb4a52cafe8eb1b3..832f2c75e3825a8d3519b89bedc884102efaab96 100644 (file)
@@ -1,3 +1,13 @@
+2019-03-31  Harald Anlauf  <anlauf@gmx.de>
+
+       Backport from trunk
+       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-25  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/71861
index d239cf114e12a1a756aec99179c6452d127961db..f4890aa06c43d1b49396093de7df0ea264aba9f6 100644 (file)
@@ -111,6 +111,7 @@ gfc_element_size (gfc_expr *e)
     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 385be8a2c97dfd2a6e39b8cfe650eca47ac2c14b..a010cf85d3001dac85bff4031b7d0a358bfc9762 100644 (file)
@@ -1157,6 +1157,9 @@ gfc_typenode_for_spec (gfc_typespec * spec, int codim)
            basetype = pfunc_type_node;
        }
        break;
+    case BT_PROCEDURE:
+      basetype = pfunc_type_node;
+      break;
     default:
       gcc_unreachable ();
     }
index cdcb617ca6a67606e42afdb8151d1f7226032b2e..d6c7e3b8357b4a58c59208de5e4f63da5e8f6daf 100644 (file)
@@ -1,3 +1,10 @@
+2019-03-31  Harald Anlauf  <anlauf@gmx.de>
+
+       Backport from trunk
+       PR fortran/83515
+       PR fortran/85797
+       * gfortran.dg/pr85797.f90: New test.
+
 2019-02-26  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/pr85797.f90 b/gcc/testsuite/gfortran.dg/pr85797.f90
new file mode 100644 (file)
index 0000000..fe6d96d
--- /dev/null
@@ -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