From: Chung-Lin Tang Date: Fri, 11 Mar 2022 13:50:52 +0000 (+0800) Subject: openmp: Allow classes with static members to be mappable X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28ea857df2ef384627b3bc803c8a5a4ce037e6b2;p=thirdparty%2Fgcc.git openmp: Allow classes with static members to be mappable 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. --- diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index cf433acde652..ccb98fdc1935 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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; diff --git a/gcc/testsuite/g++.dg/gomp/unmappable-1.C b/gcc/testsuite/g++.dg/gomp/unmappable-1.C index d00ccb5ad796..aba8497003f2 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 /* { 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() {} };