diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 851af1b30dc..a293a7b9592 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -983,6 +983,14 @@ allocatable_check (gfc_expr *e, int n) return false; } + if (attr.codimension && gfc_is_coindexed (e)) + { + gfc_error ("%qs argument of %qs intrinsic at %L shall not be " + "coindexed", gfc_current_intrinsic_arg[n]->name, + gfc_current_intrinsic, &e->where); + return false; + } + return true; } diff --git a/gcc/testsuite/gfortran.dg/coarray_allocated.f90 b/gcc/testsuite/gfortran.dg/coarray_allocated.f90 new file mode 100644 index 00000000000..70e865c94ac --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_allocated.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } +! PR fortran/93834 - ICE in trans_caf_is_present + +program p + integer, allocatable :: a[:] + print *, allocated (a) + print *, allocated (a[1]) ! { dg-error "shall not be coindexed" } +end