gcc/fortran/ChangeLog:
PR fortran/103590
* resolve.cc (find_array_spec): Change function result to bool to
enable error recovery. Generate error message for invalid array
reference of non-array entity instead of an internal error.
(gfc_resolve_ref): Use function result from find_array_spec for
error recovery.
gcc/testsuite/ChangeLog:
PR fortran/103590
* gfortran.dg/associate_54.f90: Adjust.
* gfortran.dg/associate_59.f90: New test.
static void
resolve_assoc_var (gfc_symbol* sym, bool resolve_target);
-static void
+static bool
find_array_spec (gfc_expr *e)
{
gfc_array_spec *as;
{
case REF_ARRAY:
if (as == NULL)
- gfc_internal_error ("find_array_spec(): Missing spec");
+ {
+ gfc_error ("Invalid array reference of a non-array entity at %L",
+ &ref->u.ar.where);
+ return false;
+ }
ref->u.ar.as = as;
as = NULL;
if (as != NULL)
gfc_internal_error ("find_array_spec(): unused as(2)");
+
+ return true;
}
for (ref = expr->ref; ref; ref = ref->next)
if (ref->type == REF_ARRAY && ref->u.ar.as == NULL)
{
- find_array_spec (expr);
+ if (!find_array_spec (expr))
+ return false;
break;
}
integer, intent(in) :: a
associate (state => obj%state(TEST_STATES)) ! { dg-error "is used as array" }
! state = a
- state(TEST_STATE) = a
+ state(TEST_STATE) = a ! { dg-error "array reference of a non-array" }
end associate
end subroutine test_alter_state1
end module test
-
--- /dev/null
+! { dg-do compile }
+! PR fortran/103590 - ICE: find_array_spec(): Missing spec
+! Contributed by G.Steinmetz
+
+program p
+ associate (a => 1)
+ print *, [character(a(1)) :: '1'] ! { dg-error "Scalar INTEGER expression" }
+ end associate
+end