public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <fortran@gcc.gnu.org>, Jakub Jelinek <jakub@redhat.com>,
	Tobias Burnus <tobias@codesourcery.com>,
	Thomas Schwinge <thomas@codesourcery.com>,
	Chung-Lin Tang <cltang@codesourcery.com>
Subject: [PATCH 5/5] Mapping of components of references to pointers to structs for OpenMP/OpenACC
Date: Fri, 14 May 2021 14:27:38 -0700	[thread overview]
Message-ID: <5b175bd107bcacf3946ac63f043406bfdd80d8f3.1621026372.git.julian@codesourcery.com> (raw)
In-Reply-To: <cover.1621026371.git.julian@codesourcery.com>

GCC currently raises a parse error for indirect accesses to struct
members, where the base of the access is a reference to a pointer.
This patch fixes that case.

OK for trunk?

Thanks,

Julian

2021-05-14  Julian Brown  <julian@codesourcery.com>

gcc/cp/
	* semantics.c (finish_omp_clauses): Handle components of references to
	pointers to structs.

libgomp/
	* testsuite/libgomp.oacc-c++/deep-copy-17.C: Update test.
---
 gcc/cp/semantics.c                                | 7 ++++++-
 libgomp/testsuite/libgomp.oacc-c++/deep-copy-17.C | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 0d590c318fb..b09023f741c 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7670,7 +7670,12 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 	  if ((ort == C_ORT_ACC || ort == C_ORT_OMP)
 	      && TREE_CODE (t) == COMPONENT_REF
 	      && TREE_CODE (TREE_OPERAND (t, 0)) == INDIRECT_REF)
-	    t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
+	    {
+	      t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
+	      /* References to pointers have a double indirection here.  */
+	      if (TREE_CODE (t) == INDIRECT_REF)
+		t = TREE_OPERAND (t, 0);
+	    }
 	  if (TREE_CODE (t) == COMPONENT_REF
 	      && ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP
 		  || ort == C_ORT_ACC)
diff --git a/libgomp/testsuite/libgomp.oacc-c++/deep-copy-17.C b/libgomp/testsuite/libgomp.oacc-c++/deep-copy-17.C
index dacbb520f3d..e038e9e3802 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/deep-copy-17.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/deep-copy-17.C
@@ -83,7 +83,7 @@ void strrp (void)
   a[0] = 8;
   c[0] = 10;
   e[0] = 12;
-  #pragma acc parallel copy(n->a[0:10], n->c[0:10], n->e[0:10])
+  #pragma acc parallel copy(n->a[0:10], n->b, n->c[0:10], n->d, n->e[0:10])
   {
     n->a[0] = n->c[0] + n->e[0];
   }
-- 
2.29.2


  parent reply	other threads:[~2021-05-14 21:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 21:26 [PATCH 0/5] OpenACC/OpenMP: Rework struct component handling Julian Brown
2021-05-14 21:26 ` [PATCH 1/5] Unify ARRAY_REF/INDIRECT_REF stripping code in extract_base_bit_offset Julian Brown
2021-05-14 21:26 ` [PATCH 2/5] Refactor struct lowering for OpenMP/OpenACC in gimplify.c Julian Brown
2021-05-14 21:26 ` [PATCH 3/5] Rewrite GOMP_MAP_ATTACH_DETACH mappings for OpenMP also Julian Brown
2021-05-14 21:26 ` [PATCH 4/5] Rework indirect struct handling for OpenACC/OpenMP in gimplify.c Julian Brown
2021-05-17 12:12   ` Bernd Edlinger
2021-05-17 14:10     ` Julian Brown
2021-05-14 21:27 ` Julian Brown [this message]
2021-05-17 13:07   ` [PATCH 5/5] Mapping of components of references to pointers to structs for OpenMP/OpenACC Chung-Lin Tang
2021-05-17 14:12     ` Julian Brown

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=5b175bd107bcacf3946ac63f043406bfdd80d8f3.1621026372.git.julian@codesourcery.com \
    --to=julian@codesourcery.com \
    --cc=cltang@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=thomas@codesourcery.com \
    --cc=tobias@codesourcery.com \
    /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).