diff mbox

[Fortran,OOP] PR 70601: [5/6/7/8 Regression] [OOP] ICE on procedure pointer component call

Message ID CAKwh3qiTB-72BGrrunx_-ftbfCQsYJtZ6gXb8wkz6_RJ5XBooQ@mail.gmail.com
State New
Headers show

Commit Message

Janus Weil June 5, 2017, 2:59 p.m. UTC
Hi all,

I have just committed the attached one-line patch to trunk as obvious.
It fixes an ICE-on-valid regression with procedure-pointer components.

I plan to backport it to the release branches soon (if there are no
objections) ...

Cheers,
Janus
diff mbox

Patch

Index: gcc/testsuite/gfortran.dg/proc_ptr_comp_50.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_ptr_comp_50.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/proc_ptr_comp_50.f90	(revision 248878)
@@ -0,0 +1,26 @@ 
+! { dg-do compile }
+!
+! PR 70601: [5/6/7 Regression] [OOP] ICE on procedure pointer component call
+!
+! Contributed by zmi <zmi007@gmail.com>
+
+program test
+  implicit none
+
+  type :: concrete_type
+    procedure (run_concrete_type), pointer :: run
+  end type
+
+  type(concrete_type), allocatable :: concrete
+
+  allocate(concrete)
+  concrete % run => run_concrete_type
+  call concrete % run()
+
+contains
+
+   subroutine run_concrete_type(this)
+      class(concrete_type) :: this
+   end subroutine
+
+end
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 248877)
+++ gcc/testsuite/ChangeLog	(revision 248878)
@@ -1,3 +1,8 @@ 
+2017-06-05  Janus Weil  <janus@gcc.gnu.org>
+
+	PR fortran/70601
+	* gfortran.dg/proc_ptr_comp_50.f90: New test.
+
 2017-06-05  Nicolas Koenig  <koenigni@student.ethz.ch>
 
 	PR fortran/35339
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c	(revision 248877)
+++ gcc/fortran/trans-expr.c	(revision 248878)
@@ -6132,7 +6132,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
      after use. This necessitates the creation of a temporary to
      hold the result to prevent duplicate calls.  */
   if (!byref && sym->ts.type != BT_CHARACTER
-      && sym->attr.allocatable && !sym->attr.dimension)
+      && sym->attr.allocatable && !sym->attr.dimension && !comp)
     {
       tmp = gfc_create_var (TREE_TYPE (se->expr), NULL);
       gfc_add_modify (&se->pre, tmp, se->expr);
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(revision 248877)
+++ gcc/fortran/ChangeLog	(revision 248878)
@@ -1,3 +1,9 @@ 
+2017-06-05  Janus Weil  <janus@gcc.gnu.org>
+
+	PR fortran/70601
+	* trans-expr.c (gfc_conv_procedure_call): Fix detection of allocatable
+	function results.
+
 2017-06-05  Nicolas Koenig  <koenigni@student.ethz.ch>
 
 	PR fortran/35339