public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5992] openmp: Avoid calling operand_equal_p on OMP_CLAUSEs [PR103704]
Date: Wed, 15 Dec 2021 09:29:51 +0000 (GMT)	[thread overview]
Message-ID: <20211215092951.A22C23858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:c0e34451ae582c901a2df08498b36f68ae401f0a

commit r12-5992-gc0e34451ae582c901a2df08498b36f68ae401f0a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Dec 15 10:27:08 2021 +0100

    openmp: Avoid calling operand_equal_p on OMP_CLAUSEs [PR103704]
    
    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.

Diff:
---
 gcc/cp/semantics.c                   |  3 +++
 gcc/testsuite/g++.dg/gomp/pr103704.C | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d8b20ff5b1b..356fb83200c 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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
index 00000000000..68767c4c055
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr103704.C
@@ -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> () {} };


                 reply	other threads:[~2021-12-15  9:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211215092951.A22C23858D28@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).