aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gimplify.cc')
-rw-r--r--gcc/gimplify.cc64
1 files changed, 51 insertions, 13 deletions
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 320920e..7549436 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -7699,6 +7699,25 @@ omp_default_clause (struct gimplify_omp_ctx *ctx, tree decl,
return flags;
}
+/* Return string name for types of OpenACC constructs from ORT_* values. */
+
+static const char *
+oacc_region_type_name (enum omp_region_type region_type)
+{
+ switch (region_type)
+ {
+ case ORT_ACC_DATA:
+ return "data";
+ case ORT_ACC_PARALLEL:
+ return "parallel";
+ case ORT_ACC_KERNELS:
+ return "kernels";
+ case ORT_ACC_SERIAL:
+ return "serial";
+ default:
+ gcc_unreachable ();
+ }
+}
/* Determine outer default flags for DECL mentioned in an OACC region
but not declared in an enclosing clause. */
@@ -7706,7 +7725,23 @@ omp_default_clause (struct gimplify_omp_ctx *ctx, tree decl,
static unsigned
oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
{
- const char *rkind;
+ struct gimplify_omp_ctx *ctx_default = ctx;
+ /* If no 'default' clause appears on this compute construct... */
+ if (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_SHARED)
+ {
+ /* ..., see if one appears on a lexically containing 'data'
+ construct. */
+ while ((ctx_default = ctx_default->outer_context))
+ {
+ if (ctx_default->region_type == ORT_ACC_DATA
+ && ctx_default->default_kind != OMP_CLAUSE_DEFAULT_SHARED)
+ break;
+ }
+ /* If not, reset. */
+ if (!ctx_default)
+ ctx_default = ctx;
+ }
+
bool on_device = false;
bool is_private = false;
bool declared = is_oacc_declared (decl);
@@ -7738,14 +7773,12 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
switch (ctx->region_type)
{
case ORT_ACC_KERNELS:
- rkind = "kernels";
-
if (is_private)
flags |= GOVD_FIRSTPRIVATE;
else if (AGGREGATE_TYPE_P (type))
{
/* Aggregates default to 'present_or_copy', or 'present'. */
- if (ctx->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
+ if (ctx_default->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
flags |= GOVD_MAP;
else
flags |= GOVD_MAP | GOVD_MAP_FORCE_PRESENT;
@@ -7758,8 +7791,6 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
case ORT_ACC_PARALLEL:
case ORT_ACC_SERIAL:
- rkind = ctx->region_type == ORT_ACC_PARALLEL ? "parallel" : "serial";
-
if (is_private)
flags |= GOVD_FIRSTPRIVATE;
else if (on_device || declared)
@@ -7767,7 +7798,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
else if (AGGREGATE_TYPE_P (type))
{
/* Aggregates default to 'present_or_copy', or 'present'. */
- if (ctx->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
+ if (ctx_default->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
flags |= GOVD_MAP;
else
flags |= GOVD_MAP | GOVD_MAP_FORCE_PRESENT;
@@ -7785,16 +7816,23 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
if (DECL_ARTIFICIAL (decl))
; /* We can get compiler-generated decls, and should not complain
about them. */
- else if (ctx->default_kind == OMP_CLAUSE_DEFAULT_NONE)
+ else if (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_NONE)
{
error ("%qE not specified in enclosing OpenACC %qs construct",
- DECL_NAME (lang_hooks.decls.omp_report_decl (decl)), rkind);
- inform (ctx->location, "enclosing OpenACC %qs construct", rkind);
- }
- else if (ctx->default_kind == OMP_CLAUSE_DEFAULT_PRESENT)
+ DECL_NAME (lang_hooks.decls.omp_report_decl (decl)),
+ oacc_region_type_name (ctx->region_type));
+ if (ctx_default != ctx)
+ inform (ctx->location, "enclosing OpenACC %qs construct and",
+ oacc_region_type_name (ctx->region_type));
+ inform (ctx_default->location,
+ "enclosing OpenACC %qs construct with %qs clause",
+ oacc_region_type_name (ctx_default->region_type),
+ "default(none)");
+ }
+ else if (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_PRESENT)
; /* Handled above. */
else
- gcc_checking_assert (ctx->default_kind == OMP_CLAUSE_DEFAULT_SHARED);
+ gcc_checking_assert (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_SHARED);
return flags;
}