public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, OpenMP, C++] Allow classes with static members to be mappable
@ 2022-03-09 11:04 Chung-Lin Tang
  2022-05-05  9:12 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Chung-Lin Tang @ 2022-03-09 11:04 UTC (permalink / raw)
  To: gcc-patches, Jakub Jelinek, Catherine Moore

[-- 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() {}
 };
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-17 12:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 11:04 [PATCH, OpenMP, C++] Allow classes with static members to be mappable Chung-Lin Tang
2022-05-05  9:12 ` Jakub Jelinek
2022-07-27 11:45   ` Tobias Burnus
2022-08-17 12:13     ` Jakub Jelinek

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