]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/65024 ([OOP] unlimited polymorphic pointer structure not built when...
authorPaul Thomas <pault@gcc.gnu.org>
Tue, 10 Mar 2015 22:24:01 +0000 (22:24 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Tue, 10 Mar 2015 22:24:01 +0000 (22:24 +0000)
2015-03-10  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/65024
* trans-expr.c (gfc_conv_component_ref): If the component
backend declaration is missing and the derived type symbol is
available in the reference, call gfc_build_derived_type.

2015-03-10  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/65024
* gfortran.dg/unlimited_polymorphic_23.f90: New test

From-SVN: r221338

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90 [new file with mode: 0644]

index 6fa1ee908c6844157ad7bfe7350b1d22ff21e4e5..38f8b96c79b76f05ffb77783f0b44a1dd03cf726 100644 (file)
@@ -1,3 +1,11 @@
+2015-03-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backported from mainline
+       PR fortran/65024
+       * trans-expr.c (gfc_conv_component_ref): If the component
+       backend declaration is missing and the derived type symbol is
+       available in the reference, call gfc_build_derived_type.
+
 2015-02-13  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/63744
index 2b06304cb080680e01363239684c56476517118f..098bfdfec5b75b7e4c2adc8b9fd1be2ea8124a3d 100644 (file)
@@ -1657,10 +1657,12 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref)
 
   c = ref->u.c.component;
 
-  gcc_assert (c->backend_decl);
+  if (c->backend_decl == NULL_TREE
+      && ref->u.c.sym != NULL)
+    gfc_get_derived_type (ref->u.c.sym);
 
   field = c->backend_decl;
-  gcc_assert (TREE_CODE (field) == FIELD_DECL);
+  gcc_assert (field && TREE_CODE (field) == FIELD_DECL);
   decl = se->expr;
 
   /* Components can correspond to fields of different containing
index c321c6cb7db7cdc1b28e320c3e421a04178b9e4f..a25355ad0fa11468950000ec17893174e1ea6b16 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backported from mainline
+       PR fortran/65024
+       * gfortran.dg/unlimited_polymorphic_23.f90: New test
+
 2015-03-10  Martin Sebor  <msebor@redhat.com>
 
        PR testsuite/63175
diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90
new file mode 100644 (file)
index 0000000..27eff31
--- /dev/null
@@ -0,0 +1,35 @@
+! {dg-do run }
+!
+! Test the fix for PR65024, in which the structure for the 'info'
+! component of type 'T' was not being converted into TREE_SSA and
+! so caused an ICE in trans-expr.c:gfc_conv_component_ref.
+!
+! Reported by  <matt@gneilson.plus.com>
+!
+MODULE X
+  TYPE T
+    CLASS(*), pointer :: info
+  END TYPE
+END MODULE
+
+PROGRAM P
+  call bug
+CONTAINS
+  SUBROUTINE BUG
+    USE X
+    CLASS(T), pointer :: e
+    integer, target :: i = 42
+    allocate(e)
+    e%info => NULL ()      ! used to ICE
+    if (.not.associated(e%info)) e%info => i      ! used to ICE
+    select type (z => e%info)
+      type is (integer)
+        if (z .ne.i) call abort
+    end select
+  END SUBROUTINE
+
+  SUBROUTINE NEXT
+    USE X
+    CLASS (T), pointer :: e
+  END SUBROUTINE
+END