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 + ! + program test + implicit none + real :: a(4) + ! integer :: i + read(0) (a(i),i=1,4) ! { dg-error "has no IMPLICIT type" } + end program