public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-12] OpenMP/Fortran: Permit assumed-size arrays in uniform clause
Date: Fri, 29 Jul 2022 10:45:20 +0000 (GMT)	[thread overview]
Message-ID: <20220729104520.7A6103858424@sourceware.org> (raw)

https://gcc.gnu.org/g:547a6252e94837e143f13bd7f8dc5f38dd5acd1a

commit 547a6252e94837e143f13bd7f8dc5f38dd5acd1a
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Fri Jul 29 12:39:35 2022 +0200

    OpenMP/Fortran: Permit assumed-size arrays in uniform clause
    
    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)

Diff:
---
 gcc/fortran/ChangeLog.omp                         |  8 ++++++
 gcc/fortran/openmp.cc                             |  3 ++-
 gcc/testsuite/ChangeLog.omp                       |  7 ++++++
 gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 | 30 +++++++++++++++++++++++
 4 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 5e1b91afa82..9877be5ec41 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -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:
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 264e6e6a215..91af90c3f66 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -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)
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 89b5283cdba..808cc47c0e8 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -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
index 00000000000..b94587ef35a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90
@@ -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


                 reply	other threads:[~2022-07-29 10:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220729104520.7A6103858424@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).