Dear All, I intend to commit this patch tonight, unless there are objections. It is safe, since it skips an ICE if the conditions in the ChangeLog are met.
Bootstraps and regtests on x86_64/FC21. Paul 2013-04-09 Paul Thomas <pa...@gcc.gnu.org> PR fortran/56852 * primary.c (gfc_variable_attr): Avoid ICE on AR_UNKNOWN if any of the index variables are untyped and errors are present. 2013-04-09 Paul Thomas <pa...@gcc.gnu.org> PR fortran/56852 * gfortran.dg/pr56852.f90 : New test
Index: gcc/fortran/primary.c =================================================================== *** gcc/fortran/primary.c (revision 221941) --- gcc/fortran/primary.c (working copy) *************** check_substring: *** 2138,2144 **** symbol_attribute gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts) { ! int dimension, codimension, pointer, allocatable, target; symbol_attribute attr; gfc_ref *ref; gfc_symbol *sym; --- 2138,2144 ---- symbol_attribute gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts) { ! int dimension, codimension, pointer, allocatable, target, n; symbol_attribute attr; gfc_ref *ref; gfc_symbol *sym; *************** gfc_variable_attr (gfc_expr *expr, gfc_t *** 2195,2201 **** break; case AR_UNKNOWN: ! gfc_internal_error ("gfc_variable_attr(): Bad array reference"); } break; --- 2195,2219 ---- break; case AR_UNKNOWN: ! /* If any of start, end or stride is not integer, there will ! already have been an error issued. */ ! for (n = 0; n < ref->u.ar.as->rank; n++) ! { ! int errors; ! gfc_get_errors (NULL, &errors); ! if (((ref->u.ar.start[n] ! && ref->u.ar.start[n]->ts.type == BT_UNKNOWN) ! || ! (ref->u.ar.end[n] ! && ref->u.ar.end[n]->ts.type == BT_UNKNOWN) ! || ! (ref->u.ar.stride[n] ! && ref->u.ar.stride[n]->ts.type == BT_UNKNOWN)) ! && errors > 0) ! break; ! } ! if (n == ref->u.ar.as->rank) ! gfc_internal_error ("gfc_variable_attr(): Bad array reference"); } break; Index: gcc/testsuite/gfortran.dg/pr56852.f90 =================================================================== *** gcc/testsuite/gfortran.dg/pr56852.f90 (revision 0) --- gcc/testsuite/gfortran.dg/pr56852.f90 (working copy) *************** *** 0 **** --- 1,11 ---- + ! { dg-do compile } + ! Test the fix for pr56852, where an ICE would occur after the error. + ! + ! Contributed by Lorenz Huedepohl <b...@stellardeath.org> + ! + program test + implicit none + real :: a(4) + ! integer :: i + read(0) (a(i),i=1,4) ! { dg-error "has no IMPLICIT type" } + end program