This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] Fix PR38709, ice-on-invalid-code
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 4 Apr 2009 18:31:44 +0200
- Subject: [patch, fortran] Fix PR38709, ice-on-invalid-code
Attached patch fixes an ICE-on-invalid with zero-sized arrays in
initialization expressions.
2009-04-04 Daniel Franke <franke.daniel@gmail.com>
PR fortran/38709
* expr.c (find_array_section): Leave early on zero-sized arrays.
2009-04-04 Daniel Franke <franke.daniel@gmail.com>
PR fortran/38709
* gfortran.dg/zero_sized_6.f90: New.
Regression tested on i686-pc-linux-gnu. Ok for trunk?
Cheers
Daniel
Index: expr.c
===================================================================
--- expr.c (revision 145538)
+++ expr.c (working copy)
@@ -1210,7 +1210,12 @@ find_array_section (gfc_expr *expr, gfc_
}
gcc_assert (begin->rank == 1);
- gcc_assert (begin->shape);
+ /* Zero-sized arrays have no shape, 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);
! { 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