]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Avoid calling operand_equal_p on OMP_CLAUSEs [PR103704]
authorJakub Jelinek <jakub@redhat.com>
Wed, 15 Dec 2021 09:27:08 +0000 (10:27 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 15 Dec 2021 09:27:08 +0000 (10:27 +0100)
On OMP_CLAUSEs we reuse TREE_TYPE as CP_OMP_CLAUSE_INFO in the C++ FE.
This confuses the hashing code that operand_equal_p does when checking.
There is really no reason to compare OMP_CLAUSEs against expressions
like captured this, they will never compare equal.

2021-12-15  Jakub Jelinek  <jakub@redhat.com>

PR c++/103704
* semantics.c (finish_omp_target_clauses_r): For OMP_CLAUSEs
just walk subtrees.

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

gcc/cp/semantics.c
gcc/testsuite/g++.dg/gomp/pr103704.C [new file with mode: 0644]

index d8b20ff5b1bd67db57a09a3b9a1a756e83a4ff01..356fb83200cc238263a77937ff1bd6234f49bb9d 100644 (file)
@@ -9325,6 +9325,9 @@ finish_omp_target_clauses_r (tree *tp, int *walk_subtrees, void *ptr)
       return NULL_TREE;
     }
 
+  if (TREE_CODE (t) == OMP_CLAUSE)
+    return NULL_TREE;
+
   if (current_object)
     {
       tree this_expr = TREE_OPERAND (current_object, 0);
diff --git a/gcc/testsuite/g++.dg/gomp/pr103704.C b/gcc/testsuite/g++.dg/gomp/pr103704.C
new file mode 100644 (file)
index 0000000..68767c4
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/103704
+// { dg-do compile }
+
+struct S { int a; };
+
+template <typename T>
+struct U : public T {
+  T a;
+  U ()
+  {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute private(a)
+    for (int k = 0; k < 1; ++k)
+      ;
+  }
+};
+
+struct V : public U<S> { V () : U<S> () {} };