From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 872C23858D28; Thu, 5 Jan 2023 11:01:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 872C23858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672916465; bh=1MB/gG/68KwkTRs7CYXlFHTvwGYkon9pvxIBhcHvZuE=; h=From:To:Subject:Date:From; b=D/aJTEcVZEcTZateKH/0sH4CveIZWrKNRVI9psUMJryPZ0RHe0S7Pbedvdr0edUvj oGGscurUhG5qwidt6LKcoRtbkJAtRMSnwMRGpfI5BkDi5wXhktIAyTJgedaUdyZng7 wj5S/mfqguKi2RfSy7T1KwOxbFrcInV3JobPdFzU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5006] openmp: Fix up finish_omp_target_clauses [PR108286] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 72ce780a497eb3e5efe7a79ea5f21f8dd6858f7f X-Git-Newrev: 29c3218618ef6177dc33871b26c8fbd9b21eabe1 Message-Id: <20230105110105.872C23858D28@sourceware.org> Date: Thu, 5 Jan 2023 11:01:05 +0000 (GMT) List-Id: https://gcc.gnu.org/g:29c3218618ef6177dc33871b26c8fbd9b21eabe1 commit r13-5006-g29c3218618ef6177dc33871b26c8fbd9b21eabe1 Author: Jakub Jelinek Date: Thu Jan 5 11:57:30 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 PR c++/108286 * semantics.cc (finish_omp_target_clauses): Ignore clauses other than OMP_CLAUSE_MAP. * testsuite/libgomp.c++/pr108286.C: New test. Diff: --- gcc/cp/semantics.cc | 4 +++- libgomp/testsuite/libgomp.c++/pr108286.C | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index ab52e56d6c1..ef5bf2430b1 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -9825,7 +9825,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/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 (); +}