if (ret == NULL_TREE)
return ret;
ret = c_finish_omp_master (loc, block);
+ OMP_MASTER_COMBINED (ret) = 1;
return ret;
}
}
block);
if (ret == NULL)
return ret;
- OMP_PARALLEL_COMBINED (stmt) = 1;
+ /* master doesn't have any clauses and during gimplification
+ isn't represented by a gimplification omp context, so for
+ #pragma omp parallel master don't set OMP_PARALLEL_COMBINED,
+ so that
+ #pragma omp parallel master
+ #pragma omp taskloop simd lastprivate (x)
+ isn't confused with
+ #pragma omp parallel master taskloop simd lastprivate (x) */
+ if (OMP_MASTER_COMBINED (ret))
+ OMP_PARALLEL_COMBINED (stmt) = 1;
return stmt;
}
else if (strcmp (p, "loop") == 0)
tree body = finish_omp_structured_block (sb);
if (ret == NULL)
return ret;
- return c_finish_omp_master (loc, body);
+ ret = c_finish_omp_master (loc, body);
+ OMP_MASTER_COMBINED (ret) = 1;
+ return ret;
}
}
if (!flag_openmp) /* flag_openmp_simd */
block);
if (ret == NULL_TREE)
return ret;
- OMP_PARALLEL_COMBINED (stmt) = 1;
+ /* master doesn't have any clauses and during gimplification
+ isn't represented by a gimplification omp context, so for
+ #pragma omp parallel master don't set OMP_PARALLEL_COMBINED,
+ so that
+ #pragma omp parallel master
+ #pragma omp taskloop simd lastprivate (x)
+ isn't confused with
+ #pragma omp parallel master taskloop simd lastprivate (x) */
+ if (OMP_MASTER_COMBINED (ret))
+ OMP_PARALLEL_COMBINED (stmt) = 1;
return stmt;
}
else if (strcmp (p, "loop") == 0)
}
if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c))
flags |= GOVD_LASTPRIVATE_CONDITIONAL;
- if (outer_ctx
- && (outer_ctx->region_type == ORT_COMBINED_PARALLEL
- || ((outer_ctx->region_type & ORT_COMBINED_TEAMS)
- == ORT_COMBINED_TEAMS))
- && splay_tree_lookup (outer_ctx->variables,
- (splay_tree_key) decl) == NULL)
- {
- omp_add_variable (outer_ctx, decl, GOVD_SHARED | GOVD_SEEN);
- if (outer_ctx->outer_context)
- omp_notice_variable (outer_ctx->outer_context, decl, true);
- }
- else if (outer_ctx
- && (outer_ctx->region_type & ORT_TASK) != 0
- && outer_ctx->combined_loop
- && splay_tree_lookup (outer_ctx->variables,
- (splay_tree_key) decl) == NULL)
- {
- omp_add_variable (outer_ctx, decl, GOVD_LASTPRIVATE | GOVD_SEEN);
- if (outer_ctx->outer_context)
- omp_notice_variable (outer_ctx->outer_context, decl, true);
- }
- else if (outer_ctx
- && (outer_ctx->region_type == ORT_WORKSHARE
- || outer_ctx->region_type == ORT_ACC)
- && outer_ctx->combined_loop
- && splay_tree_lookup (outer_ctx->variables,
- (splay_tree_key) decl) == NULL
- && !omp_check_private (outer_ctx, decl, false))
- {
- omp_add_variable (outer_ctx, decl, GOVD_LASTPRIVATE | GOVD_SEEN);
- if (outer_ctx->outer_context
- && (outer_ctx->outer_context->region_type
- == ORT_COMBINED_PARALLEL)
- && splay_tree_lookup (outer_ctx->outer_context->variables,
+ struct gimplify_omp_ctx *octx;
+ for (octx = outer_ctx; octx; octx = octx->outer_context)
+ {
+ if ((octx->region_type == ORT_COMBINED_PARALLEL
+ || ((octx->region_type & ORT_COMBINED_TEAMS)
+ == ORT_COMBINED_TEAMS))
+ && splay_tree_lookup (octx->variables,
(splay_tree_key) decl) == NULL)
{
- struct gimplify_omp_ctx *octx = outer_ctx->outer_context;
omp_add_variable (octx, decl, GOVD_SHARED | GOVD_SEEN);
- if (octx->outer_context)
- {
- octx = octx->outer_context;
- if (octx->region_type == ORT_WORKSHARE
- && octx->combined_loop
- && splay_tree_lookup (octx->variables,
- (splay_tree_key) decl) == NULL
- && !omp_check_private (octx, decl, false))
- {
- omp_add_variable (octx, decl,
- GOVD_LASTPRIVATE | GOVD_SEEN);
- octx = octx->outer_context;
- if (octx
- && ((octx->region_type & ORT_COMBINED_TEAMS)
- == ORT_COMBINED_TEAMS)
- && (splay_tree_lookup (octx->variables,
- (splay_tree_key) decl)
- == NULL))
- {
- omp_add_variable (octx, decl,
- GOVD_SHARED | GOVD_SEEN);
- octx = octx->outer_context;
- }
- }
- if (octx)
- omp_notice_variable (octx, decl, true);
- }
+ continue;
}
- else if (outer_ctx->outer_context)
- omp_notice_variable (outer_ctx->outer_context, decl, true);
+ if ((octx->region_type & ORT_TASK) != 0
+ && octx->combined_loop
+ && splay_tree_lookup (octx->variables,
+ (splay_tree_key) decl) == NULL)
+ {
+ omp_add_variable (octx, decl, GOVD_LASTPRIVATE | GOVD_SEEN);
+ continue;
+ }
+ if ((octx->region_type == ORT_WORKSHARE
+ || octx->region_type == ORT_ACC)
+ && octx->combined_loop
+ && splay_tree_lookup (octx->variables,
+ (splay_tree_key) decl) == NULL
+ && !omp_check_private (octx, decl, false))
+ {
+ omp_add_variable (octx, decl, GOVD_LASTPRIVATE | GOVD_SEEN);
+ continue;
+ }
+ if (octx->region_type == ORT_COMBINED_TARGET
+ && splay_tree_lookup (octx->variables,
+ (splay_tree_key) decl) == NULL)
+ {
+ omp_add_variable (octx, decl, GOVD_MAP | GOVD_SEEN);
+ octx = octx->outer_context;
+ break;
+ }
+ break;
}
+ if (octx && octx != outer_ctx)
+ omp_notice_variable (octx, decl, true);
goto do_add;
case OMP_CLAUSE_REDUCTION:
if (OMP_CLAUSE_REDUCTION_TASK (c))
g = gimple_build_omp_section (body);
break;
case OMP_MASTER:
- g = gimple_build_omp_master (body);
+ g = gimple_build_omp_master (body);
break;
case OMP_ORDERED:
g = gimplify_omp_ordered (*expr_p, body);
--- /dev/null
+/* PR middle-end/99928 */
+/* { dg-do compile } */
+
+int
+foo (void)
+{
+ int l = 0;
+ #pragma omp parallel master taskloop simd lastprivate (l) default(none) /* { dg-bogus "'l' not specified in enclosing 'parallel'" } */
+ for (int i = 0; i < 16; i++)
+ l = i;
+ return l;
+}
+
+int
+bar (void)
+{
+ int l = 0;
+ #pragma omp parallel master default(none) /* { dg-message "enclosing 'parallel'" } */
+ #pragma omp taskloop simd lastprivate (l) /* { dg-error "'l' not specified in enclosing 'parallel'" } */
+ for (int i = 0; i < 16; i++)
+ l = i;
+ return l;
+}
#pragma omp section
l10 = 2;
}
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l11" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l11\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l11" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l11\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp parallel\[^\n\r]*lastprivate\\(l11\\)" "gimple" } } *//* FIXME: This should be on for instead. */
/* { dg-final { scan-tree-dump-not "omp for\[^\n\r]*lastprivate\\(l11\\)" "gimple" } } *//* FIXME. */
#pragma omp target parallel for lastprivate (l11)
for (int i = 0; i < 64; i++)
l11 = i;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l12" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l12\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l12" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l12\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp parallel\[^\n\r]*lastprivate\\(l12\\)" "gimple" } } *//* FIXME: This should be on for instead. */
/* { dg-final { scan-tree-dump-not "omp for\[^\n\r]*lastprivate\\(l12\\)" "gimple" } } *//* FIXME. */
/* { dg-final { scan-tree-dump "omp simd\[^\n\r]*lastprivate\\(l12\\)" "gimple" } } */
#pragma omp target parallel for simd lastprivate (l12)
for (int i = 0; i < 64; i++)
l12 = i;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:j01" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(j01\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:j01" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(j01\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp parallel\[^\n\r]*shared\\(j01\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp for\[^\n\r]*lastprivate\\(j01\\)" "gimple" } } *//* NOTE: This is implementation detail. */
/* { dg-final { scan-tree-dump "omp simd\[^\n\r]*lastprivate\\(j01\\)" "gimple" } } *//* NOTE: This is implementation detail. */
#pragma omp target parallel loop lastprivate (j01)
for (j01 = 0; j01 < 64; j01++)
;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l13" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l13\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l13" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l13\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp teams\[^\n\r]*shared\\(l13\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp distribute\[^\n\r]*lastprivate\\(l13\\)" "gimple" } } */
#pragma omp target teams distribute lastprivate (l13)
for (int i = 0; i < 64; i++)
l13 = i;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l14" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l14\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l14" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l14\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp teams\[^\n\r]*shared\\(l14\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp distribute\[^\n\r]*lastprivate\\(l14\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp parallel\[^\n\r]*lastprivate\\(l14\\)" "gimple" } } *//* FIXME: This should be on for instead. */
#pragma omp target teams distribute parallel for lastprivate (l14)
for (int i = 0; i < 64; i++)
l14 = i;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l15" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l15\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l15" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l15\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp teams\[^\n\r]*shared\\(l15\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp distribute\[^\n\r]*lastprivate\\(l15\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp parallel\[^\n\r]*lastprivate\\(l15\\)" "gimple" } } *//* FIXME: This should be on for instead. */
#pragma omp target teams distribute parallel for simd lastprivate (l15)
for (int i = 0; i < 64; i++)
l15 = i;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l16" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l16\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l16" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l16\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp teams\[^\n\r]*shared\\(l16\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp distribute\[^\n\r]*lastprivate\\(l16\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp simd\[^\n\r]*lastprivate\\(l16\\)" "gimple" } } */
#pragma omp target teams distribute simd lastprivate (l16)
for (int i = 0; i < 64; i++)
l16 = i;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:j02" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(j02\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:j02" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(j02\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp teams\[^\n\r]*shared\\(j02\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp distribute\[^\n\r]*lastprivate\\(j02\\)" "gimple" } } *//* NOTE: This is implementation detail. */
/* { dg-final { scan-tree-dump "omp parallel\[^\n\r]*shared\\(j02\\)" "gimple" } } *//* NOTE: This is implementation detail. */
#pragma omp target teams loop lastprivate (j02)
for (j02 = 0; j02 < 64; j02++)
;
- /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l17" "gimple" { xfail *-*-* } } } */
- /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l17\\)" "gimple" { xfail *-*-* } } } */
+ /* { dg-final { scan-tree-dump "omp target\[^\n\r]*map\\(tofrom:l17" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "omp target\[^\n\r]*firstprivate\\(l17\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "omp simd\[^\n\r]*lastprivate\\(l17\\)" "gimple" } } */
#pragma omp target simd lastprivate (l17)
for (int i = 0; i < 64; i++)
#define OMP_TARGET_COMBINED(NODE) \
(OMP_TARGET_CHECK (NODE)->base.private_flag)
+/* True on an OMP_MASTER statement if it represents an explicit
+ combined master constructs. */
+#define OMP_MASTER_COMBINED(NODE) \
+ (OMP_MASTER_CHECK (NODE)->base.private_flag)
+
/* Memory order for OMP_ATOMIC*. */
#define OMP_ATOMIC_MEMORY_ORDER(NODE) \
(TREE_RANGE_CHECK (NODE, OMP_ATOMIC, \