Dear Fortranners, here's a pretty obvious one: we didn't properly check the arguments for intrinsics when these had to be ALLOCATABLE and in the case that argument was a coarray object. Simple solution: just reuse a check that was used for pointer etc.
Regtested on x86_64-pc-linux-gnu. OK for mainline / backports? Thanks, Harald Fortran - extend allocatable_check to coarrays gcc/fortran/ChangeLog: PR fortran/93834 * check.c (allocatable_check): A coindexed array element is not an allocatable object. gcc/testsuite/ChangeLog: PR fortran/93834 * gfortran.dg/coarray_allocated.f90: New test.
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