aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimplify.c2
-rw-r--r--gcc/testsuite/c-c++-common/gomp/scope-4.c11
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 1067113..f4bc649 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -10195,7 +10195,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/c-c++-common/gomp/scope-4.c b/gcc/testsuite/c-c++-common/gomp/scope-4.c
new file mode 100644
index 0000000..924ae9c
--- /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;
+}