https://gcc.gnu.org/g:120efb3931260de35173267ec6870d8f17fbadb5
commit r15-9945-g120efb3931260de35173267ec6870d8f17fbadb5 Author: Andre Vehreschild <ve...@gcc.gnu.org> Date: Wed Jul 2 11:06:17 2025 +0200 Fortran: Remove corank conformability checks [PR120843] Remove the checks on coranks conformability in expressions, because there is nothing in the standard about it. When a coarray has no coindexes it it treated like a non-coarray, when it has a full-corank coindex its result is a regular array. So nothing to check for corank conformability. PR fortran/120843 gcc/fortran/ChangeLog: * resolve.cc (resolve_operator): Remove conformability check, because it is not in the standard. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coindexed_6.f90: Enhance test to have coarray components covered. (cherry picked from commit 15413e05eb9cde976b8890cd9b597d0a41a8eb27) Diff: --- gcc/fortran/resolve.cc | 29 ----------------------- gcc/testsuite/gfortran.dg/coarray/coindexed_6.f90 | 13 +++++++--- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 2fbe7c451428..760526eb4029 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -4807,35 +4807,6 @@ resolve_operator (gfc_expr *e) return false; } } - - /* coranks have to be equal or one has to be zero to be combinable. */ - if (op1->corank == op2->corank || (op1->corank != 0 && op2->corank == 0)) - { - e->corank = op1->corank; - /* Only do this, when regular array has not set a shape yet. */ - if (e->shape == NULL) - { - if (op1->corank != 0) - { - e->shape = gfc_copy_shape (op1->shape, op1->corank); - } - } - } - else if (op1->corank == 0 && op2->corank != 0) - { - e->corank = op2->corank; - /* Only do this, when regular array has not set a shape yet. */ - if (e->shape == NULL) - e->shape = gfc_copy_shape (op2->shape, op2->corank); - } - else if ((op1->ref && !gfc_ref_this_image (op1->ref)) - || (op2->ref && !gfc_ref_this_image (op2->ref))) - { - gfc_error ("Inconsistent coranks for operator at %L and %L", - &op1->where, &op2->where); - return false; - } - break; case INTRINSIC_PARENTHESES: diff --git a/gcc/testsuite/gfortran.dg/coarray/coindexed_6.f90 b/gcc/testsuite/gfortran.dg/coarray/coindexed_6.f90 index 8f5dcabb859a..d566c504134f 100644 --- a/gcc/testsuite/gfortran.dg/coarray/coindexed_6.f90 +++ b/gcc/testsuite/gfortran.dg/coarray/coindexed_6.f90 @@ -5,13 +5,20 @@ program p implicit none - integer, allocatable :: arr(:,:) [:,:] + type T + integer, allocatable :: arr(:,:) [:,:] + end type + + type(T) :: o + integer, allocatable :: vec(:)[:,:] integer :: c[*] c = 7 - allocate(arr(4,3)[2,*], source=6) + allocate(o%arr(4,3)[2,*], source=6) + allocate(vec(10)[1,*], source=7) - if (arr(2,2)* c /= 42) stop 1 + if (vec(3) * c /= 49) stop 1 + if (o%arr(2,2)* c /= 42) stop 2 end program p