From: Janus Weil Date: Fri, 11 Jun 2010 01:42:38 +0000 (+0200) Subject: re PR fortran/44207 (ICE with ALLOCATABLE components and SOURCE) X-Git-Tag: releases/gcc-4.6.0~6580 X-Git-Url: https://gcc.gnu.org/git/?a=commitdiff_plain;h=66051b6074a5641299738aa1d698fc63175ca0de;p=gcc.git re PR fortran/44207 (ICE with ALLOCATABLE components and SOURCE) 2010-06-10 Janus Weil PR fortran/44207 * resolve.c (conformable_arrays): Handle allocatable components. 2010-06-10 Janus Weil PR fortran/44207 * gfortran.dg/allocate_alloc_opt_7.f90: New test. From-SVN: r160589 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5988845a40ef..6cf60ee47b2d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2010-06-10 Janus Weil + + PR fortran/44207 + * resolve.c (conformable_arrays): Handle allocatable components. + 2010-06-10 Francois-Xavier Coudert PR fortran/38273 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 226c2f9197bc..4b4c50559c32 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f5ca670d60bf..b2ffe20bc55b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-06-10 Janus Weil + + PR fortran/44207 + * gfortran.dg/allocate_alloc_opt_7.f90: New test. + 2010-06-10 Daniel Franke 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 index 000000000000..e77f6b7c6380 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_7.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! +! PR 44207: ICE with ALLOCATABLE components and SOURCE +! +! Contributed by Hans-Werner Boschmann + +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