re PR fortran/38709 (ICE on zero-sized array in initialization expression)

gcc/fortran/:
2009-04-10  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/38709
        * expr.c (find_array_section): Leave early on zero-sized arrays.


gcc/testsuite/:
2009-04-10  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/38709
        * gfortran.dg/zero_sized_6.f90: New.

From-SVN: r145909
This commit is contained in:
Daniel Franke 2009-04-10 10:12:01 -04:00 committed by Daniel Franke
parent 7ef455560c
commit 045ac36715
4 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2009-04-10 Daniel Franke <franke.daniel@gmail.com>
PR fortran/38709
* expr.c (find_array_section): Leave early on zero-sized arrays.
2009-04-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/36704

View File

@ -1210,7 +1210,12 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
}
gcc_assert (begin->rank == 1);
gcc_assert (begin->shape);
/* Zero-sized arrays have no shape and no elements, stop early. */
if (!begin->shape)
{
mpz_init_set_ui (nelts, 0);
break;
}
vecsub[d] = begin->value.constructor;
mpz_set (ctr[d], vecsub[d]->expr->value.integer);

View File

@ -1,3 +1,8 @@
2009-04-10 Daniel Franke <franke.daniel@gmail.com>
PR fortran/38709
* gfortran.dg/zero_sized_6.f90: New.
2009-04-10 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/20118

View File

@ -0,0 +1,6 @@
! { dg-do "compile" }
! PR38709 - ICE-on-invalid on zero-sized array in init-expr.
INTEGER, PARAMETER :: a(1) = (/ 1 /)
INTEGER, PARAMETER :: i = a(shape(1)) ! { dg-error "Incompatible ranks" }
END