public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-11] openmp: Disallow reduction with var private in containing parallel even on scope [PR102504]
Date: Thu, 30 Sep 2021 07:51:08 +0000 (GMT)	[thread overview]
Message-ID: <20210930075108.569B33858C39@sourceware.org> (raw)

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

commit a5709263af0a0b64b28b51762594c185a418d061
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Sep 29 11:16:26 2021 +0200

    openmp: Disallow reduction with var private in containing parallel even on scope [PR102504]
    
    The standard has a restriction:
    "A list item that appears in a reduction clause of a scope construct must be
    shared in the parallel region to which a corresponding scope region binds."
    similar to the restriction for worksharing constructs, but we were checking
    it only on worksharing constructs and not for scope and ICEd later on during
    omp expansion.
    
    2021-09-29  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/102504
            * gimplify.c (gimplify_scan_omp_clauses): Use omp_check_private even
            in OMP_SCOPE clauses, not just on worksharing construct clauses.
    
            * c-c++-common/gomp/scope-4.c: New test.
    
    (cherry picked from commit d3e7bb15e28c554bf4484a912f3b9c18c60ec68f)

Diff:
---
 gcc/ChangeLog.omp                         |  9 +++++++++
 gcc/gimplify.c                            |  2 +-
 gcc/testsuite/ChangeLog.omp               |  8 ++++++++
 gcc/testsuite/c-c++-common/gomp/scope-4.c | 11 +++++++++++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index e519764cd73..f0e787d8dd2 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-09-29  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-09-29  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/102504
+	* gimplify.c (gimplify_scan_omp_clauses): Use omp_check_private even
+	in OMP_SCOPE clauses, not just on worksharing construct clauses.
+
 2021-09-28  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 8a324f6081b..f51c1f7318c 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -10780,7 +10780,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
 	  if (outer_ctx)
 	    omp_notice_variable (outer_ctx, decl, true);
 	  if (check_non_private
-	      && region_type == ORT_WORKSHARE
+	      && (region_type == ORT_WORKSHARE || code == OMP_SCOPE)
 	      && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
 		  || decl == OMP_CLAUSE_DECL (c)
 		  || (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 64904d1cb16..46c27e16d4d 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,11 @@
+2021-09-29  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-09-29  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/102504
+	* c-c++-common/gomp/scope-4.c: New test.
+
 2021-09-28  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/c-c++-common/gomp/scope-4.c b/gcc/testsuite/c-c++-common/gomp/scope-4.c
new file mode 100644
index 00000000000..924ae9cbb24
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/scope-4.c
@@ -0,0 +1,11 @@
+/* PR middle-end/102504 */
+/* { dg-do compile } */
+
+int
+foo ()
+{
+  int r = 0;
+  #pragma omp scope reduction(+:r)	/* { dg-error "reduction variable 'r' is private in outer context" } */
+  r++;
+  return r;
+}


                 reply	other threads:[~2021-09-30  7:51 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=20210930075108.569B33858C39@sourceware.org \
    --to=burnus@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).