aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/gimplify.c21
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr101535-1.c31
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr101535-2.c11
3 files changed, 58 insertions, 5 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 93a2121..5d43f76 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7798,7 +7798,13 @@ omp_check_private (struct gimplify_omp_ctx *ctx, tree decl, bool copyprivate)
if ((ctx->region_type & (ORT_TARGET | ORT_TARGET_DATA)) != 0
&& (n == NULL || (n->value & GOVD_DATA_SHARE_CLASS) == 0))
- continue;
+ {
+ if ((ctx->region_type & ORT_TARGET_DATA) != 0
+ || n == NULL
+ || (n->value & GOVD_MAP) == 0)
+ continue;
+ return false;
+ }
if (n != NULL)
{
@@ -7807,11 +7813,16 @@ omp_check_private (struct gimplify_omp_ctx *ctx, tree decl, bool copyprivate)
return false;
return (n->value & GOVD_SHARED) == 0;
}
+
+ if (ctx->region_type == ORT_WORKSHARE
+ || ctx->region_type == ORT_TASKGROUP
+ || ctx->region_type == ORT_SIMD
+ || ctx->region_type == ORT_ACC)
+ continue;
+
+ break;
}
- while (ctx->region_type == ORT_WORKSHARE
- || ctx->region_type == ORT_TASKGROUP
- || ctx->region_type == ORT_SIMD
- || ctx->region_type == ORT_ACC);
+ while (1);
return false;
}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr101535-1.c b/gcc/testsuite/c-c++-common/gomp/pr101535-1.c
new file mode 100644
index 0000000..8285ce0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr101535-1.c
@@ -0,0 +1,31 @@
+/* PR middle-end/101535 */
+
+void
+foo (void)
+{
+ int a = 1, i;
+ #pragma omp target data map(to:a)
+ #pragma omp for lastprivate(i) /* { dg-error "lastprivate variable 'i' is private in outer context" } */
+ for (i = 1; i < 2; i++)
+ ;
+}
+
+void
+bar (void)
+{
+ int a = 1, i;
+ #pragma omp target private(i)
+ #pragma omp for lastprivate(i) /* { dg-error "lastprivate variable 'i' is private in outer context" } */
+ for (i = 1; i < 2; i++)
+ ;
+}
+
+void
+baz (void)
+{
+ int a = 1, i;
+ #pragma omp target firstprivate(i)
+ #pragma omp for lastprivate(i) /* { dg-error "lastprivate variable 'i' is private in outer context" } */
+ for (i = 1; i < 2; i++)
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr101535-2.c b/gcc/testsuite/c-c++-common/gomp/pr101535-2.c
new file mode 100644
index 0000000..23c84af
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr101535-2.c
@@ -0,0 +1,11 @@
+/* PR middle-end/101535 */
+
+void
+foo (void)
+{
+ int a = 1, i;
+ #pragma omp target map(tofrom:i)
+ #pragma omp for lastprivate(i)
+ for (i = 1; i < 2; i++)
+ ;
+}