diff mbox series

[fortran] PR83515, PR85797 - ICE in gfc_element_size

Message ID 5C92BC90.4070104@gmx.de
State New
Headers show
Series [fortran] PR83515, PR85797 - ICE in gfc_element_size | expand

Commit Message

Harald Anlauf March 20, 2019, 10:20 p.m. UTC
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  <anlauf@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  <anlauf@gmx.de>

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

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

Comments

Harald Anlauf March 27, 2019, 7:34 p.m. UTC | #1
Ping!?

On 03/20/19 23:20, Harald Anlauf wrote:
> 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  <anlauf@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  <anlauf@gmx.de>
>
> 	PR fortran/83515
> 	PR fortran/85797
> 	* gfortran.dg/pr85797.f90: New test.
>
Harald Anlauf March 31, 2019, 6:33 p.m. UTC | #2
Committed to trunk as svn rev. 270045.

Since the patch is considered safe, I also committed to open branches (7/8).

Thanks for the review!

Harald

On 03/20/19 23:20, Harald Anlauf wrote:
> 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  <anlauf@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  <anlauf@gmx.de>
>
> 	PR fortran/83515
> 	PR fortran/85797
> 	* gfortran.dg/pr85797.f90: New test.
>
diff mbox series

Patch

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 ();
     }