From: Chung-Lin Tang <cltang@codesourcery.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
Jakub Jelinek <jakub@redhat.com>,
Catherine Moore <clm@codesourcery.com>
Subject: [PATCH, OpenMP, C++] Allow classes with static members to be mappable
Date: Wed, 9 Mar 2022 19:04:24 +0800 [thread overview]
Message-ID: <45836136-ada7-500e-8fd1-c4f2b4ae515b@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 811 bytes --]
Hi Jakub,
Now in OpenMP 5.x, static members are supposed to be not a barrier for a class
to be target-mapped.
There is the related issue of actually providing access to static const/constexpr
members on the GPU (probably a case of https://github.com/OpenMP/spec/issues/2158)
but that is for later.
This patch basically just removes the check for static members inside
cp_omp_mappable_type_1, and adjusts a testcase. Not sure if more tests are needed.
Tested on trunk without regressions, okay when stage1 reopens?
Thanks,
Chung-Lin
2022-03-09 Chung-Lin Tang <cltang@codesourcery.com>
gcc/cp/ChangeLog:
* decl2.cc (cp_omp_mappable_type_1): Remove requirement that all
members must be non-static; remove check for static fields.
gcc/testsuite/ChangeLog:
* g++.dg/gomp/unmappable-1.C: Adjust testcase.
[-- Attachment #2: g.diff --]
[-- Type: text/plain, Size: 1409 bytes --]
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index c53acf4546d..ace7783d9bd 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -1544,21 +1544,14 @@ cp_omp_mappable_type_1 (tree type, bool notes)
/* Arrays have mappable type if the elements have mappable type. */
while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type);
- /* All data members must be non-static. */
+
if (CLASS_TYPE_P (type))
{
tree field;
for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
- if (VAR_P (field))
- {
- if (notes)
- inform (DECL_SOURCE_LOCATION (field),
- "static field %qD is not mappable", field);
- result = false;
- }
/* All fields must have mappable types. */
- else if (TREE_CODE (field) == FIELD_DECL
- && !cp_omp_mappable_type_1 (TREE_TYPE (field), notes))
+ if (TREE_CODE (field) == FIELD_DECL
+ && !cp_omp_mappable_type_1 (TREE_TYPE (field), notes))
result = false;
}
return result;
diff --git a/gcc/testsuite/g++.dg/gomp/unmappable-1.C b/gcc/testsuite/g++.dg/gomp/unmappable-1.C
index 364f884500c..1532b9c73f1 100644
--- a/gcc/testsuite/g++.dg/gomp/unmappable-1.C
+++ b/gcc/testsuite/g++.dg/gomp/unmappable-1.C
@@ -4,7 +4,7 @@
class C
{
public:
- static int static_member; /* { dg-message "static field .C::static_member. is not mappable" } */
+ static int static_member;
virtual void f() {}
};
next reply other threads:[~2022-03-09 11:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-09 11:04 Chung-Lin Tang [this message]
2022-05-05 9:12 ` Jakub Jelinek
2022-07-27 11:45 ` Tobias Burnus
2022-08-17 12:13 ` Jakub Jelinek
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=45836136-ada7-500e-8fd1-c4f2b4ae515b@codesourcery.com \
--to=cltang@codesourcery.com \
--cc=clm@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.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).