public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-12] openmp: Fix up finish_omp_target_clauses [PR108286]
@ 2023-01-09 10:58 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2023-01-09 10:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8f0788600840869e9fa016ff08ad07eb485a4f83

commit 8f0788600840869e9fa016ff08ad07eb485a4f83
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jan 9 11:54:33 2023 +0100

    openmp: Fix up finish_omp_target_clauses [PR108286]
    
    The comment in the loop says that we shouldn't add a map clause if such
    a clause exists already, but the loop was actually using OMP_CLAUSE_DECL
    on any clause.  Target construct can have various clauses which don't
    have OMP_CLAUSE_DECL at all (e.g. nowait, device or if) or clause
    where it means something different (e.g. privatization clauses, allocate,
    depend).
    
    So, only check OMP_CLAUSE_DECL on OMP_CLAUSE_MAP clauses.
    
    2023-01-05  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/108286
            * semantics.cc (finish_omp_target_clauses): Ignore clauses other than
            OMP_CLAUSE_MAP.
    
            * testsuite/libgomp.c++/pr108286.C: New test.
    
    (cherry picked from commit 29c3218618ef6177dc33871b26c8fbd9b21eabe1)

Diff:
---
 gcc/cp/ChangeLog.omp                     |  9 +++++++++
 gcc/cp/semantics.cc                      |  4 +++-
 gcc/testsuite/ChangeLog.omp              |  8 ++++++++
 libgomp/testsuite/libgomp.c++/pr108286.C | 29 +++++++++++++++++++++++++++++
 4 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 2652871ea21..f386cdea157 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,12 @@
+2023-01-09  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from mainline:
+	2023-01-05  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108286
+	* semantics.cc (finish_omp_target_clauses): Ignore clauses other than
+	OMP_CLAUSE_MAP.
+
 2022-12-21  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from mainline:
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index b8fe7eed72a..ce17aae8224 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -9933,7 +9933,9 @@ finish_omp_target_clauses (location_t loc, tree body, tree *clauses_ptr)
 
 	for (tree c = *clauses_ptr; c; c = OMP_CLAUSE_CHAIN (c))
 	  {
-	    /* If map(this->ptr[:N] already exists, avoid creating another
+	    if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
+	      continue;
+	    /* If map(this->ptr[:N]) already exists, avoid creating another
 	       such map.  */
 	    tree decl = OMP_CLAUSE_DECL (c);
 	    if ((TREE_CODE (decl) == INDIRECT_REF
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index d018d9b0dbc..ae810eb4ead 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,11 @@
+2023-01-09  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from mainline:
+	2023-01-05  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108286
+	* testsuite/libgomp.c++/pr108286.C: New test.
+
 2023-01-03  Sandra Loosemore  <sandra@codesourcery.com>
 
 	Backported from master:
diff --git a/libgomp/testsuite/libgomp.c++/pr108286.C b/libgomp/testsuite/libgomp.c++/pr108286.C
new file mode 100644
index 00000000000..ee88c2f9fd0
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr108286.C
@@ -0,0 +1,29 @@
+// PR c++/108286
+// { dg-do run }
+
+struct S {
+  int
+  foo ()
+  {
+    int res = 0;
+#pragma omp target map(size, ptr[:size], res) nowait
+    res = ptr[size - 1];
+#pragma omp taskwait
+    return res;
+  }
+
+  unsigned size;
+  int *ptr;
+};
+
+int
+main ()
+{
+  S s;
+  int buf[5];
+  s.size = 5;
+  s.ptr = buf;
+  buf[4] = 42;
+  if (s.foo () != 42)
+    __builtin_abort ();
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-09 10:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 10:58 [gcc/devel/omp/gcc-12] openmp: Fix up finish_omp_target_clauses [PR108286] Tobias Burnus

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).