diff mbox series

[committed] Improve is-coindexed check for OpenACC/OpenMP (was: [PATCH 10/13] OpenACC 2.6 deep copy: Fortran front-end parts)

Message ID c355a1b8-0bd1-9345-13a9-f105b19043fb@codesourcery.com
State New
Headers show
Series [committed] Improve is-coindexed check for OpenACC/OpenMP (was: [PATCH 10/13] OpenACC 2.6 deep copy: Fortran front-end parts) | expand

Commit Message

Tobias Burnus Dec. 20, 2019, 11:23 a.m. UTC
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
diff mbox series

Patch

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  <tobias@codesourcery.com>
 
+	* gfortran.dg/goacc/coindexed-1.f90: New.
+
+2019-12-20  Tobias Burnus  <tobias@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  <tobias@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  <julian@codesourcery.com>
 
 	* openmp.c (resolve_oacc_data_clauses): Don't disallow allocatable