2010-06-10 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Jun 2010 01:42:38 +0000 (01:42 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Jun 2010 01:42:38 +0000 (01:42 +0000)
PR fortran/44207
* resolve.c (conformable_arrays): Handle allocatable components.

2010-06-10  Janus Weil  <janus@gcc.gnu.org>

PR fortran/44207
* gfortran.dg/allocate_alloc_opt_7.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160589 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/allocate_alloc_opt_7.f90 [new file with mode: 0644]

index 5988845..6cf60ee 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-10  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/44207
+       * resolve.c (conformable_arrays): Handle allocatable components.
+
 2010-06-10  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/38273
index 226c2f9..4b4c505 100644 (file)
@@ -6146,8 +6146,11 @@ gfc_expr_to_initialize (gfc_expr *e)
 static gfc_try
 conformable_arrays (gfc_expr *e1, gfc_expr *e2)
 {
+  gfc_ref *tail;
+  for (tail = e2->ref; tail && tail->next; tail = tail->next);
+  
   /* First compare rank.  */
-  if (e2->ref && e1->rank != e2->ref->u.ar.as->rank)
+  if (tail && e1->rank != tail->u.ar.as->rank)
     {
       gfc_error ("Source-expr at %L must be scalar or have the "
                 "same rank as the allocate-object at %L",
@@ -6164,15 +6167,15 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2)
 
       for (i = 0; i < e1->rank; i++)
        {
-         if (e2->ref->u.ar.end[i])
+         if (tail->u.ar.end[i])
            {
-             mpz_set (s, e2->ref->u.ar.end[i]->value.integer);
-             mpz_sub (s, s, e2->ref->u.ar.start[i]->value.integer);
+             mpz_set (s, tail->u.ar.end[i]->value.integer);
+             mpz_sub (s, s, tail->u.ar.start[i]->value.integer);
              mpz_add_ui (s, s, 1);
            }
          else
            {
-             mpz_set (s, e2->ref->u.ar.start[i]->value.integer);
+             mpz_set (s, tail->u.ar.start[i]->value.integer);
            }
 
          if (mpz_cmp (e1->shape[i], s) != 0)
index f5ca670..b2ffe20 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-10  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/44207
+       * gfortran.dg/allocate_alloc_opt_7.f90: New test.
+
 2010-06-10  Daniel Franke  <franke.daniel@gmail.com>
 
        PR fortran/44457
diff --git a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_7.f90 b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_7.f90
new file mode 100644 (file)
index 0000000..e77f6b7
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile }
+!
+! PR 44207: ICE with ALLOCATABLE components and SOURCE
+!
+! Contributed by Hans-Werner Boschmann <boschmann@tp1.physik.uni-siegen.de>
+
+program ice_prog
+
+type::ice_type
+  integer,dimension(:),allocatable::list
+end type ice_type
+
+type(ice_type)::this
+integer::dim=10,i
+
+allocate(this%list(dim),source=[(i,i=1,dim)])
+
+end program ice_prog