re PR fortran/46344 ([OOP] ICE with allocatable CLASS components)
authorJanus Weil <janus@gcc.gnu.org>
Mon, 8 Nov 2010 09:03:50 +0000 (10:03 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Mon, 8 Nov 2010 09:03:50 +0000 (10:03 +0100)
2010-11-08  Janus Weil  <janus@gcc.gnu.org>

PR fortran/46344
* trans-types.c (gfc_copy_dt_decls_ifequal): Handle CLASS components.

2010-11-08  Janus Weil  <janus@gcc.gnu.org>

PR fortran/46344
* gfortran.dg/class_28.f03: New.

From-SVN: r166430

gcc/fortran/ChangeLog
gcc/fortran/trans-types.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_28.f03 [new file with mode: 0644]

index 92be429..a513933 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-08  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/46344
+       * trans-types.c (gfc_copy_dt_decls_ifequal): Handle CLASS components.
+
 2010-11-06  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/46330
index 1ccba7a..a597cd7 100644 (file)
@@ -1936,10 +1936,12 @@ gfc_copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to,
   for (; to_cm; to_cm = to_cm->next, from_cm = from_cm->next)
     {
       to_cm->backend_decl = from_cm->backend_decl;
-      if ((!from_cm->attr.pointer || from_gsym)
-             && from_cm->ts.type == BT_DERIVED)
+      if (from_cm->ts.type == BT_DERIVED
+         && (!from_cm->attr.pointer || from_gsym))
+       gfc_get_derived_type (to_cm->ts.u.derived);
+      else if (from_cm->ts.type == BT_CLASS
+              && (!CLASS_DATA (from_cm)->attr.class_pointer || from_gsym))
        gfc_get_derived_type (to_cm->ts.u.derived);
-
       else if (from_cm->ts.type == BT_CHARACTER)
        to_cm->ts.u.cl->backend_decl = from_cm->ts.u.cl->backend_decl;
     }
index 28d05af..395d987 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-08  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/46344
+       * gfortran.dg/class_28.f03: New.
+
 2010-11-08  Andrey Belevantsev  <abel@ispras.ru>
 
        PR rtl-optimization/45352
diff --git a/gcc/testsuite/gfortran.dg/class_28.f03 b/gcc/testsuite/gfortran.dg/class_28.f03
new file mode 100644 (file)
index 0000000..cfd46a8
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do compile }
+!
+! PR 46344: [4.6 Regression] [OOP] ICE with allocatable CLASS components
+!
+! Contributed by Salvatore Filippone <sfilippone@uniroma2.it>
+
+module m
+
+  type t1
+  end type
+
+  type  t2
+    class(t1), allocatable :: cc
+  end type
+
+  class(t2), allocatable :: sm
+
+end module m
+
+program p
+  use m
+  implicit none
+
+  type(t2), allocatable :: x(:) 
+
+  allocate(x(1))
+
+end program p
+
+! { dg-final { cleanup-modules "m" } }