public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] openmp: Disallow reduction with var private in containing parallel even on scope [PR102504]
@ 2021-09-29  8:28 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-09-29  8:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Tobias Burnus

Hi!

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.

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

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.

--- gcc/gimplify.c.jj	2021-09-28 11:37:55.905290494 +0200
+++ gcc/gimplify.c	2021-09-28 13:39:30.563366270 +0200
@@ -10195,7 +10195,7 @@ gimplify_scan_omp_clauses (tree *list_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
--- gcc/testsuite/c-c++-common/gomp/scope-4.c.jj	2021-09-28 13:45:32.694358993 +0200
+++ gcc/testsuite/c-c++-common/gomp/scope-4.c	2021-09-28 13:46:54.775224041 +0200
@@ -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;
+}

	Jakub


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-29  8:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29  8:28 [committed] openmp: Disallow reduction with var private in containing parallel even on scope [PR102504] Jakub Jelinek

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).