aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/openmp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-10-19 09:38:59 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-10-19 09:38:59 +0200
commitcd30a0b8fec5e27d43349e4d48e166f1ccde6306 (patch)
treea348b948e294ac9c727be78f3655ee80dfdf152d /gcc/fortran/openmp.c
parentbcc478b9647e2af4b715fda6676d98f1e129d16b (diff)
downloadgcc-cd30a0b8fec5e27d43349e4d48e166f1ccde6306.zip
gcc-cd30a0b8fec5e27d43349e4d48e166f1ccde6306.tar.gz
gcc-cd30a0b8fec5e27d43349e4d48e166f1ccde6306.tar.bz2
re PR fortran/82568 ([6/7/8] ICE with do-loop inside BLOCK inside omp)
PR fortran/82568 * gfortran.h (gfc_resolve_do_iterator): Add a bool arg. (gfc_resolve_omp_local_vars): New declaration. * openmp.c (omp_current_ctx): Make static. (gfc_resolve_omp_parallel_blocks): Handle EXEC_OMP_TASKLOOP and EXEC_OMP_TASKLOOP_SIMD. (gfc_resolve_do_iterator): Add ADD_CLAUSE argument, if false, don't actually add any clause. Move omp_current_ctx test earlier. (handle_local_var, gfc_resolve_omp_local_vars): New functions. * resolve.c (gfc_resolve_code): Call gfc_resolve_omp_parallel_blocks instead of just gfc_resolve_omp_do_blocks for EXEC_OMP_TASKLOOP and EXEC_OMP_TASKLOOP_SIMD. (gfc_resolve_code): Adjust gfc_resolve_do_iterator caller. (resolve_codes): Call gfc_resolve_omp_local_vars. * gfortran.dg/gomp/pr82568.f90: New test. From-SVN: r253878
Diffstat (limited to 'gcc/fortran/openmp.c')
-rw-r--r--gcc/fortran/openmp.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index c5e0088..2606323 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -5262,7 +5262,7 @@ resolve_omp_atomic (gfc_code *code)
}
-struct fortran_omp_context
+static struct fortran_omp_context
{
gfc_code *code;
hash_set<gfc_symbol *> *sharing_clauses;
@@ -5345,6 +5345,8 @@ gfc_resolve_omp_parallel_blocks (gfc_code *code, gfc_namespace *ns)
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
+ case EXEC_OMP_TASKLOOP:
+ case EXEC_OMP_TASKLOOP_SIMD:
case EXEC_OMP_TEAMS_DISTRIBUTE:
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
@@ -5390,8 +5392,11 @@ gfc_omp_restore_state (struct gfc_omp_saved_state *state)
construct, where they are predetermined private. */
void
-gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym)
+gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym, bool add_clause)
{
+ if (omp_current_ctx == NULL)
+ return;
+
int i = omp_current_do_collapse;
gfc_code *c = omp_current_do_code;
@@ -5410,9 +5415,6 @@ gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym)
c = c->block->next;
}
- if (omp_current_ctx == NULL)
- return;
-
/* An openacc context may represent a data clause. Abort if so. */
if (!omp_current_ctx->is_openmp && !oacc_is_loop (omp_current_ctx->code))
return;
@@ -5421,7 +5423,7 @@ gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym)
&& omp_current_ctx->sharing_clauses->contains (sym))
return;
- if (! omp_current_ctx->private_iterators->add (sym))
+ if (! omp_current_ctx->private_iterators->add (sym) && add_clause)
{
gfc_omp_clauses *omp_clauses = omp_current_ctx->code->ext.omp_clauses;
gfc_omp_namelist *p;
@@ -5433,6 +5435,22 @@ gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym)
}
}
+static void
+handle_local_var (gfc_symbol *sym)
+{
+ if (sym->attr.flavor != FL_VARIABLE
+ || sym->as != NULL
+ || (sym->ts.type != BT_INTEGER && sym->ts.type != BT_REAL))
+ return;
+ gfc_resolve_do_iterator (sym->ns->code, sym, false);
+}
+
+void
+gfc_resolve_omp_local_vars (gfc_namespace *ns)
+{
+ if (omp_current_ctx)
+ gfc_traverse_ns (ns, handle_local_var);
+}
static void
resolve_omp_do (gfc_code *code)