]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP/Fortran: Permit assumed-size arrays in uniform clause
authorTobias Burnus <tobias@codesourcery.com>
Fri, 29 Jul 2022 10:39:35 +0000 (12:39 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 29 Jul 2022 10:39:35 +0000 (12:39 +0200)
gcc/fortran/ChangeLog:

* openmp.cc (resolve_omp_clauses): Permit assumed-size arrays
in uniform clause.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-simd-3.f90: New test.

(cherry picked from commit a6afbe5e9528e9ec3f0426d9791bd28e6e584d82)

gcc/fortran/ChangeLog.omp
gcc/fortran/openmp.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 [new file with mode: 0644]

index 5e1b91afa82ec2a112fac1268ce162cce0a92942..9877be5ec41b0200bbd8592aaf619d9c7f322e8d 100644 (file)
@@ -1,3 +1,11 @@
+2022-07-29  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline:
+       2022-07-29  Tobias Burnus  <tobias@codesourcery.com>
+
+       * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays
+       in uniform clause.
+
 2022-07-05  Tobias Burnus  <tobias@codesourcery.com>
 
        Backport from mainline:
index 264e6e6a21590d9ffa7f72dccd552753f0045019..91af90c3f6608cb15c0ab78a645fa651b1aeb372 100644 (file)
@@ -8169,7 +8169,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
                        || code->op == EXEC_OACC_PARALLEL
                        || code->op == EXEC_OACC_SERIAL))
                  check_array_not_assumed (n->sym, n->where, name);
-               else if (n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE)
+               else if (list != OMP_LIST_UNIFORM
+                        && n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE)
                  gfc_error ("Assumed size array %qs in %s clause at %L",
                             n->sym->name, name, &n->where);
                if (n->sym->attr.in_namelist && !is_reduction)
index 89b5283cdbaa9b72cf9ba8ae14e4280aad4f431b..808cc47c0e8b250b610ddc1fdd19acd5bc6d6083 100644 (file)
@@ -1,3 +1,10 @@
+2022-07-29  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline:
+       2022-07-29  Tobias Burnus  <tobias@codesourcery.com>
+
+       * gfortran.dg/gomp/declare-simd-3.f90: New test.
+
 2022-07-29  Tobias Burnus  <tobias@codesourcery.com>
 
        Backport from mainline:
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90
new file mode 100644 (file)
index 0000000..b94587e
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do compile }
+
+module m
+  implicit none (type, external)
+contains
+  real function add(x, y, j) result(res)
+    !$omp declare simd(add) uniform(x, y) linear(j : 1) simdlen(4)
+    integer, value :: j
+    real, intent(in) :: x(*), y(*)
+    res = x(j) + y(j)
+  end function
+end module m
+
+program main
+  use m
+  implicit none (type, external)
+  real, allocatable :: A(:), B(:), C(:)
+  integer :: i, N
+  N = 128
+  A = [(3*i, i = 1, N)]
+  B = [(7*i, i = 1, N)]
+  allocate (C(N))
+
+  !$omp simd
+  do i = 1, N
+    C(i) = add(A, B, i)
+  end do
+
+  if (any (C /= [(10*i, i = 1, N)])) error stop
+end program main