Julian has committed that patch as Rev. 279628. Follow up regarding coarrays:
I had proposed to use 'gfc_is_coindexed' instead of only checking the rightmost array reference. However, it turned out that this check comes too late. (As did the check before Julian's patch.)
Namely, when checking in resolve_omp_clauses the gfc_resolve_expr seems to have called – and this changes the expression. Example: "A[2]" will be converted into a function call "_F.caf_get[[A]]" with -fcoarray=lib — or to "A" with -fcoarray=single.
Hence, I moved the coindexed check directly after parsing and added a test case for it. Coarrays by itself should be fine as they act as normal local variables – just that they are allocated by _gfortran_caf_register instead of malloc, stack or static allocation.
Committed as Rev. 279637. Cheers, Tobias
Index: gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 (revision 279637) @@ -0,0 +1,37 @@ +! { dg-do compile } +! { dg-additional-options "-fcoarray=single" } +! +subroutine check_coindexed() +implicit none +type t + integer :: i +end type t +type t2 + integer, allocatable :: i[:] + type(t), allocatable :: x[:] +end type t2 +type(t), allocatable :: A(:)[:], B(:)[:] +type(t) :: D(1)[*], E[*] +type(t2) :: C +save :: D, E + +! Coarrays are fine if they are local/not coindexed: + +!$acc enter data copyin(D(1)%i) +!$acc enter data copyin(A(1)) +!$acc enter data copyin(B(1)%i) +!$acc enter data copyin(C%i) +!$acc enter data copyin(C%x%i) +!$acc enter data copyin(C%i) +!$acc enter data copyin(C%x%i) + +! Does not like the '[' after the identifier: +!$acc enter data copyin(E[2]) ! { dg-error "Syntax error in OpenMP variable list" } + +!$acc enter data copyin(D(1)[2]%i) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(A(1)[4]) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(B(1)[4]%i) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(C%i[2]) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(C%x[4]%i) ! { dg-error "List item shall not be coindexed" } + +end Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 279636) +++ gcc/testsuite/ChangeLog (revision 279637) @@ -1,5 +1,9 @@ 2019-12-20 Tobias Burnus <tob...@codesourcery.com> + * gfortran.dg/goacc/coindexed-1.f90: New. + +2019-12-20 Tobias Burnus <tob...@codesourcery.com> + * gfortran.dg/goacc/data-clauses.f95: Remove now obsolete dg-error. Index: gcc/fortran/openmp.c =================================================================== --- gcc/fortran/openmp.c (revision 279636) +++ gcc/fortran/openmp.c (revision 279637) @@ -274,6 +274,11 @@ default: break; } + if (gfc_is_coindexed (expr)) + { + gfc_error ("List item shall not be coindexed at %C"); + goto cleanup; + } } gfc_set_sym_referenced (sym); p = gfc_get_omp_namelist (); @@ -4544,9 +4549,6 @@ gfc_error ("%qs in %s clause at %L is not a proper " "array section", n->sym->name, name, &n->where); - else if (gfc_is_coindexed (n->expr)) - gfc_error ("Entry shall not be coindexed in %s " - "clause at %L", name, &n->where); else { int i; Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (revision 279636) +++ gcc/fortran/ChangeLog (revision 279637) @@ -1,3 +1,8 @@ +2019-12-20 Tobias Burnus <tob...@codesourcery.com> + + * openmp.c (resolve_omp_clauses): Move is-coindexed check from here ... + (gfc_match_omp_variable_list): ... to here. + 2019-12-19 Julian Brown <jul...@codesourcery.com> * openmp.c (resolve_oacc_data_clauses): Don't disallow allocatable