]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Disallow reduction with var private in containing parallel even on scope...
authorJakub Jelinek <jakub@redhat.com>
Wed, 29 Sep 2021 09:16:26 +0000 (11:16 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 29 Sep 2021 09:16:42 +0000 (11:16 +0200)
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)

gcc/ChangeLog.omp
gcc/gimplify.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/scope-4.c [new file with mode: 0644]

index e519764cd73d9aefe81b929ff70f5ef6ab719ae3..f0e787d8dd20a66e07340c8cc3f06e2d709b348d 100644 (file)
@@ -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:
index 8a324f6081b88a13a070ecdfc78de7fadadfed71..f51c1f7318cfb0e57a5e6fb8fc447929e48a7417 100644 (file)
@@ -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
index 64904d1cb1642c71d2d26ef9aad68c0bbea55f55..46c27e16d4d1277e6ea69be4b17a1b6f1edc84d4 100644 (file)
@@ -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 (file)
index 0000000..924ae9c
--- /dev/null
@@ -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;
+}