Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2021-12-15  Jakub Jelinek  <ja...@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.jj       2021-12-09 15:37:27.000000000 +0100
+++ gcc/cp/semantics.c  2021-12-14 15:00:04.163009167 +0100
@@ -9325,6 +9325,9 @@ finish_omp_target_clauses_r (tree *tp, i
       return NULL_TREE;
     }
 
+  if (TREE_CODE (t) == OMP_CLAUSE)
+    return NULL_TREE;
+
   if (current_object)
     {
       tree this_expr = TREE_OPERAND (current_object, 0);
--- gcc/testsuite/g++.dg/gomp/pr103704.C.jj     2021-12-14 15:19:12.101684930 
+0100
+++ gcc/testsuite/g++.dg/gomp/pr103704.C        2021-12-14 15:18:57.895887034 
+0100
@@ -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> () {} };

        Jakub

Reply via email to