]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Allow classes with static members to be mappable
authorChung-Lin Tang <cltang@codesourcery.com>
Fri, 11 Mar 2022 13:50:52 +0000 (21:50 +0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Fri, 11 Mar 2022 13:50:52 +0000 (21:50 +0800)
In OpenMP 5.x, static members are supposed to be not a barrier for a class
to be target-mapped. Remove the check for static members inside
cp_omp_mappable_type_1, and adjusts a testcase.

Merged from:
https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591449.html

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.

gcc/cp/decl2.c
gcc/testsuite/g++.dg/gomp/unmappable-1.C

index cf433acde652644d12d5cf6254fcd9af5c7e1e49..ccb98fdc1935f854d9f0410b8d3d4c01556ce781 100644 (file)
@@ -1456,24 +1456,14 @@ cp_omp_mappable_type_1 (tree type, bool notes)
                "type %qT with virtual members is not mappable", type);
       result = false;
     }
-  /* 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)
-           /* Fields that are 'static constexpr' can be folded away at compile
-              time, thus does not interfere with mapping.  */
-           && !DECL_DECLARED_CONSTEXPR_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;
index d00ccb5ad796f840f2ee6851120efc0e096dd9ab..aba8497003f294b2978b0aae7abeb3eb3ba2275b 100644 (file)
@@ -4,7 +4,7 @@
 class C /* { dg-message "type .C. with virtual members is not mappable" } */
 {
 public:
-  static int static_member; /* { dg-message "static field .C::static_member. is not mappable" } */
+  static int static_member;
   virtual void f() {}
 };