+2013-10-19 Paul Thomas <pault@gcc.gnu.org>
+
+ Backport from trunk
+ 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.
+
2015-10-18 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport from trunk
symbol_attribute
gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
{
- int dimension, codimension, pointer, allocatable, target;
+ int dimension, codimension, pointer, allocatable, target, n;
symbol_attribute attr;
gfc_ref *ref;
gfc_symbol *sym;
break;
case AR_UNKNOWN:
- gfc_internal_error ("gfc_variable_attr(): Bad array reference");
+ /* 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;
break;
default:
- gfc_error ("Symbol at %C is not appropriate for an expression");
+ gfc_error ("Symbol '%s' at %C is not appropriate for an expression",
+ sym->name);
return MATCH_ERROR;
}
--- /dev/null
+! { dg-do compile }
+! Test the fix for pr56852, where an ICE would occur after the error.
+!
+! Contributed by Lorenz Huedepohl <bugs@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