]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Improve is-coindexed check for OpenACC/OpenMP
authorTobias Burnus <tobias@codesourcery.com>
Fri, 20 Dec 2019 11:22:52 +0000 (11:22 +0000)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 20 Dec 2019 11:22:52 +0000 (12:22 +0100)
        gcc/fortran/
        * openmp.c (resolve_omp_clauses): Move is-coindexed check from here ...
        (gfc_match_omp_variable_list): ... to here.

        gcc/testsuite/
        * gfortran.dg/goacc/coindexed-1.f90: New.

From-SVN: r279637

gcc/fortran/ChangeLog
gcc/fortran/openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 [new file with mode: 0644]

index 355ded48e0f80dd374ab1afa7be2776a84e9e2ec..d382ac056668b84dd19aba1668850e54d3e5cf65 100644 (file)
@@ -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
index 051b4bd0a6cdf1463b5435705576001d3a9f0a0a..01964f964d790f493312a56799e4130f191d5545 100644 (file)
@@ -274,6 +274,11 @@ gfc_match_omp_variable_list (const char *str, gfc_omp_namelist **list,
                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 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
                      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 77730594a00db8147aa017245ceabd3994a356de..8f2aba2f7edf7241c00f80d7b0d8011f712e9a52 100644 (file)
@@ -1,3 +1,7 @@
+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
diff --git a/gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 b/gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90
new file mode 100644 (file)
index 0000000..7e0d1dd
--- /dev/null
@@ -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