openmp: Fix up handling of DECL_OMP_PRIVATIZED_MEMBER for bit-fields [PR95063]
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 May 2020 08:00:32 +0000 (10:00 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 12 May 2020 08:05:27 +0000 (10:05 +0200)
The r11-15 change broke this testcase, as it now asserts type is equal to
the type of the DECL_VALUE_EXPR, but for DECL_OMP_PRIVATIZED_MEMBER artificial
vars mapping to bitfields it wasn't.  Fixed by changing the
DECL_OMP_PRIVATIZED_MEMBER var type in that case.

2020-05-12  Jakub Jelinek  <jakub@redhat.com>

PR c++/95063
* pt.c (tsubst_decl): Deal with DECL_OMP_PRIVATIZED_MEMBER for
a bit-field.

* g++.dg/gomp/pr95063.C: New test.

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr95063.C [new file with mode: 0644]

index 5cf9dda42e2c8800e455c06a1dd9f69c9b3b6de8..db80907ef4d26525f28d08a53fc070c9c5029564 100644 (file)
@@ -1,3 +1,9 @@
+2020-05-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/95063
+       * pt.c (tsubst_decl): Deal with DECL_OMP_PRIVATIZED_MEMBER for
+       a bit-field.
+
 2020-05-11  Jason Merrill  <jason@redhat.com>
 
        Resolve C++20 NB comment CA104
index 84864561c2581d7578fcf595a18244854f11c29c..7911293571e21a3b865680da01d8aa555fca0761 100644 (file)
@@ -14627,6 +14627,12 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
                  }
                if (nop)
                  ve = build_nop (type, ve);
+               else if (DECL_LANG_SPECIFIC (t)
+                        && DECL_OMP_PRIVATIZED_MEMBER (t)
+                        && TREE_CODE (ve) == COMPONENT_REF
+                        && TREE_CODE (TREE_OPERAND (ve, 1)) == FIELD_DECL
+                        && DECL_BIT_FIELD_TYPE (TREE_OPERAND (ve, 1)) == type)
+                 type = TREE_TYPE (ve);
                else
                  gcc_checking_assert (TREE_TYPE (ve) == type);
                SET_DECL_VALUE_EXPR (r, ve);
index dc7eb3141a43a3cde0e0ffbd2c2f284636e9d987..0c8a73a30a4074e12153b0589836e31b81954290 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/95063
+       * g++.dg/gomp/pr95063.C: New test.
+
 2020-05-12  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/94980
diff --git a/gcc/testsuite/g++.dg/gomp/pr95063.C b/gcc/testsuite/g++.dg/gomp/pr95063.C
new file mode 100644 (file)
index 0000000..fe5894c
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/95063
+
+template <typename T>
+struct S {
+  T a : 12;
+  S () : a(0)
+  {
+#pragma omp for linear(a)
+    for (int k = 0; k < 64; ++k)
+      a++;
+  }
+};
+struct U {
+  int a : 12;
+  U () : a(0)
+  {
+#pragma omp for linear(a)
+    for (int k = 0; k < 64; ++k)
+      a++;
+  }
+};
+
+S<int> s;
+U u;