Skip to content

Commit 55d8c54

Browse files
committed
Fortran: improve error recovery while simplifying size of bad array [PR103694]
gcc/fortran/ChangeLog: PR fortran/103694 * simplify.cc (simplify_size): The size expression of an array cannot be simplified if an error occurs while resolving the array spec. gcc/testsuite/ChangeLog: PR fortran/103694 * gfortran.dg/pr103694.f90: New test.
1 parent 530f804 commit 55d8c54

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

gcc/fortran/simplify.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7536,8 +7536,9 @@ simplify_size (gfc_expr *array, gfc_expr *dim, int k)
75367536
}
75377537

75387538
for (ref = array->ref; ref; ref = ref->next)
7539-
if (ref->type == REF_ARRAY && ref->u.ar.as)
7540-
gfc_resolve_array_spec (ref->u.ar.as, 0);
7539+
if (ref->type == REF_ARRAY && ref->u.ar.as
7540+
&& !gfc_resolve_array_spec (ref->u.ar.as, 0))
7541+
return NULL;
75417542

75427543
if (dim == NULL)
75437544
{
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
! { dg-do compile }
2+
! PR fortran/103694 - ICE in gfc_conv_expr_op
3+
! Contributed by G.Steinmetz
4+
5+
subroutine s
6+
type t
7+
integer :: a(2)
8+
end type
9+
type(t) :: x((0.)/0)
10+
integer :: n = size(x(1)%a) ! { dg-error "does not reduce to a constant expression" }
11+
end

0 commit comments

Comments
 (0)